Skip to content

Instantly share code, notes, and snippets.

View shaunthegeek's full-sized avatar
👊
Fighting

Shaun shaunthegeek

👊
Fighting
View GitHub Profile
@shaunthegeek
shaunthegeek / MergeTwoPPTX.vba
Last active July 1, 2023 02:01
Merge two PPT files page by page in order
Sub MergeTwoPPTX()
Dim strSlidesPath1 As String
Dim strSlidesPath2 As String
Dim pageCount As Long
Dim oTarget As Presentation
strSlidesPath1 = "/Users/sink/Downloads/XYL-7.pptx"
strSlidesPath2 = "/Users/sink/Downloads/002-XYL-7.pptx"
' Get number of slides
@shaunthegeek
shaunthegeek / hexo-renderer-marked-anchor-alias.patch
Created September 10, 2020 09:53
hexo custom header ID(anchor alias)
diff -uNr node_modules/hexo-renderer-marked/index.js hexo-renderer-marked/index.js
--- node_modules/hexo-renderer-marked/index.js 1985-10-26 16:15:00.000000000 +0800
+++ hexo-renderer-marked/index.js 2020-09-10 16:08:59.441937082 +0800
@@ -15,6 +15,7 @@
mangle: true,
sanitizeUrl: false,
headerIds: true,
+ anchorAlias: false,
lazyload: false,
// TODO: enable prependRoot by default in v3
@shaunthegeek
shaunthegeek / Jenkinsfile
Last active July 9, 2020 07:59
Jenkins git diff files when merge request
pipeline {
agent any
stages {
stage('checkout') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*']],
userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]
])
@shaunthegeek
shaunthegeek / sub.py
Created March 28, 2020 02:26
python 提取汉字和日期
#!/usr/bin/python3
import re
str1 = """美国股市(American stock market),简称美股,泛指美国纽约的证券交易所的股票市场,主要指标包括道琼斯工业平均指数、标准普尔500指数及纳斯达克100指数。狭义来说,美股主要是指道琼斯工业平均指数的表现,例如“美股升若干点”的意思等同于“道指升若干点”。
2020年3月16日:美股开盘熔断,已经是本月第三次,美联储降息已经无力救市了吗?可能会带来哪些连锁反应?
2020年3月24日:美股开盘即大涨,是回光返照还是药到病除?
2020年3月25日:如何看待美股的暴涨?
"""
@shaunthegeek
shaunthegeek / Jenkinsfile
Created November 27, 2019 05:38
Jenkins multiple Docker containers in the background, instead of sidecar
node {
checkout scm
sh 'docker network create bridge1';
sh(script:'docker run --net bridge1 --name mysql -d -e "MYSQL_ROOT_PASSWORD=my-secret-pw" -e "MYSQL_DATABASE=test" mysql:5.7', returnStdout: true)
sh(script:'docker run --net bridge1 --name redis -d redis:5', returnStdout: true)
def testImage = docker.build("test-image:${env.BUILD_ID}", "-f Dockerfile ./")
testImage.inside('--net bridge1 -e "DB_HOST=mysql" -e "REDIS_HOST=redis" -e "DB_DATABASE=test" -e "DB_USERNAME=root" -e "DB_PASSWORD=my-secret-pw"') {
stage('Prepare') {
echo 'preparing'
sh 'env'
<?php
/**
* remove mirros of composer.lock
*/
$data = json_decode(file_get_contents(__DIR__ . '/composer.lock'), true);
$new_data = $data;
foreach (['packages', 'packages-dev'] as $key) {
if (!isset($data[$key])) {
continue;
@shaunthegeek
shaunthegeek / 2019_01_04_185416_socialite_wechat_use_unionid.patch
Created April 18, 2019 11:44
Laravel socialite 微信登录使用 union id
diff -uNr vendor/socialiteproviders/weixin/Provider.php sinkcup/socialiteproviders/weixin/Provider.php
--- vendor/socialiteproviders/weixin/Provider.php 2017-11-18 13:09:07.000000000 +0800
+++ sinkcup/socialiteproviders/weixin/Provider.php 2019-01-04 18:53:29.548886728 +0800
@@ -100,7 +100,7 @@
protected function mapUserToObject(array $user)
{
return (new User())->setRaw($user)->map([
- 'id' => $user['openid'],
+ 'id' => $user['unionid'],
'nickname' => isset($user['nickname']) ? $user['nickname'] : null,
@shaunthegeek
shaunthegeek / 2019_04_18_112223_aliyun_oss_carbon.patch
Created April 18, 2019 03:47
阿里云OSS PHP SDK补丁:使用Carbon替代time(),修复代码可测性
--- vendor/aliyuncs/oss-sdk-php/composer.json 2018-01-08 14:59:35.000000000 +0800
+++ stonecutter/aliyun-oss-php-sdk/composer.json 2019-04-18 11:13:06.799247597 +0800
@@ -11,6 +11,7 @@
}
],
"require": {
+ "nesbot/carbon": ">=1.0",
"php":">=5.3"
},
"require-dev" : {
@shaunthegeek
shaunthegeek / hack-google-translate-zh-cn.php
Last active March 13, 2018 10:28
Google Translation API "Discovering Supported Languages" missing "zh-CN", but "Detecting Languages" return "zh-CN", so we need hack it
<?php
require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\Translate\TranslateClient;
$targetLanguage = 'en'; // Print the names of the languages in which language?
$translate = new TranslateClient([
'keyFilePath' => __DIR__ . '/config/gcloud_key.json',
]);
$result = $translate->localizedLanguages([
@shaunthegeek
shaunthegeek / composer.json
Created January 10, 2018 07:40
fzaninotto/Faker imageUrl is using https://lorempixel.com, today it down again. I write a patch to switch to https://fakeimg.pl
{
"name": "laravel/laravel",
"scripts": {
"post-install-cmd": [
"patch -N -p0 < faker_image_url.patch || echo 'patch failed'"
]
}
}