Skip to content

Instantly share code, notes, and snippets.

😁
Available for Hire, Rails Developer with 4 years of Experience

Cheng Zheng 1c7

😁
Available for Hire, Rails Developer with 4 years of Experience
Block or report user

Report or block 1c7

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View docker-swarm-deploy.sh
cd /var/www/
export TAG=${BUDDY_EXECUTION_REVISION_SHORT}
envsubst < docker-stack.yml > file.tmp
sudo docker stack deploy --with-registry-auth --compose-file file.tmp buddy-cd-app
@1c7
1c7 / git-command.sh
Created Feb 10, 2019
Gitlab remote to Github remote & vice versa
View git-command.sh
## to Gitlab
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.com:1c7/empty.git
git push -u origin --all
git push -u origin --tags
## Gitlab back to Github
cd existing_repo
git remote rm origin
@1c7
1c7 / .gitlab-ci.yml
Created Feb 2, 2019
.gitlab-ci.yml example
View .gitlab-ci.yml
image: gitlab/dind
stages:
- build_and_publish_image
b_and_p:
stage: build_and_publish_image
script:
- docker login -u [username] -p [password] registry.gitlab.com
- docker build -t registry.gitlab.com/1c7/ccb .
@1c7
1c7 / job.rb
Created Jan 23, 2019
Slack webhook example curl->Ruby
View job.rb
class SlackIdVerifyJobJob < ApplicationJob
queue_as :default
def perform()
# curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/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
# Equivalent ruby code:
url = "https://hooks.slack.com/services/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"
options = {
body: {"text": "Hello, World!"}.to_json,
@1c7
1c7 / example.js
Last active Jan 8, 2019
微信小程序代码
View example.js
Page({
data: {
offsetY: 0,
},
onShow(){
this.get_image_offset();
},
get_image_offset(){
if(this.data.offsetY == 0){
var that = this;
@1c7
1c7 / snippet_for_blog.html
Created Jan 8, 2019
微信小程序代码
View snippet_for_blog.html
<image class='图片position:relative' src="{{例子}}" bind:tap='click_image' mode='widthFix'>
<view catch:tap='删除标签函数' data-tag="{{i}}" class='tag_on_image' wx:key="{{i}}" wx:for='{{tag_array}}' wx:for-item='i' data-item='{{i}}' style="position:absolute; left:{{i.x}}px;top:{{i.y}}px;">
{{i.name}}
</view>
</image>
@1c7
1c7 / 1.sh
Created Jan 1, 2019
test Ghost+Github
View 1.sh
echo "Hello Ghost from Github"
@1c7
1c7 / copy-your-subreddit-list.js
Last active Nov 30, 2018
copy your subreddit list
View copy-your-subreddit-list.js
// Step 1: visit
// https://www.reddit.com/subreddits/
// Step 2:
// copy & past these into Chrome developer tool
var array = []
document.querySelectorAll('.subscription-box ul li').forEach(function(element) {
var subreddit = element.querySelector('a[class="title"]')
subreddit_name = subreddit.innerText
@1c7
1c7 / grap youtube playlist title.js
Created Nov 24, 2018
grap youtube playlist title
View grap youtube playlist title.js
var original = $('#playlist tr span').text().split('\n')
original.splice(0,1)
var res = original.filter((element, index) => {
return index % 2 == 0;
})
var result = res.map(s => s.trim());
result.join('\n')
@1c7
1c7 / show_finger_real_time.js
Last active Nov 19, 2018
Show number of finger touch screen in Real time
View show_finger_real_time.js
$("#camera-controller").on("touchstart", (e) => {
var fingerOnScreen = e.originalEvent.targetTouches.length;
$('#finger_count').text(fingerOnScreen);
});
$("#camera-controller").on("touchend", (e) => {
var fingerOnScreen = e.originalEvent.targetTouches.length;
$('#finger_count').text(fingerOnScreen);
});
You can’t perform that action at this time.