View decodeAudioData Example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var init = function (url) { | |
var audioCtx, fail, request, source, success; | |
audioCtx = new (window.AudioContext || window.webkitAudioContext)(); | |
success = function (e) { | |
console.log("success", e); | |
}; | |
fail = function (e) { | |
console.log("fail", e); | |
}; | |
source = audioCtx.createBufferSource(); |
View ruby_upload_to_aws_s3.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk-s3' # v2 version use: require 'aws-sdk' | |
Aws.config.update({ | |
credentials: Aws::Credentials.new('x', 'x') | |
}) | |
s3 = Aws::S3::Resource.new(region: 'cn-north-1') | |
# Beijing: cn-north-1 | |
# Ningxia: cn-northwest-1 | |
file = './test_file_to_s3_bucket.txt' |
View generateAccountSASQueryParameters_demo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.azure_sas = function () { | |
var accountName = '<storage account name>' | |
var accountKey = '<account key like: xxxTAujFeBxdic/6a1SgEaoeByhqQeUpRdWaQ8Y7kRJ1rhwbXEoW8WAg036B4jkzTE9AYmtKnFu03dt6g1jJyA==>' | |
var sharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey) | |
var last_day_of_this_year = new Date(new Date().getFullYear(), 11, 31) | |
var resource_types = new AccountSASResourceTypes() | |
resource_types.container = true | |
resource_types.object = true |
View buildspec.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
# Docker caching: | |
# https://github.com/aws/aws-codebuild-docker-images/issues/26#issuecomment-370177343 | |
phases: | |
install: | |
runtime-versions: | |
docker: 18 | |
pre_build: |
View read_blob_url_content.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read blob url like this one: | |
// blob:http://localhost:8080/611963a8-1e5a-4de3-9fa2-3fa39a82a2a2 | |
// This blob url come from URL.createObjectURL(File); | |
function turn_blob_to_file(blob_url) { | |
var xhr = new XMLHttpRequest(); | |
xhr.responseType = "blob"; | |
xhr.onload = function() { | |
var blob = xhr.response; |
View docker-swarm-deploy.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View git-command.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
View .gitlab-ci.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
View job.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
View example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Page({ | |
data: { | |
offsetY: 0, | |
}, | |
onShow(){ | |
this.get_image_offset(); | |
}, | |
get_image_offset(){ | |
if(this.data.offsetY == 0){ | |
var that = this; |
NewerOlder