Skip to content

Instantly share code, notes, and snippets.

Nami WANG namiwang

Block or report user

Report or block namiwang

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
@namiwang
namiwang / patch_simulating_middleware.rb
Last active Aug 27, 2019
middleware to simulate PATCH method with a POST when client doesn't support it
View patch_simulating_middleware.rb
class PatchSimulatingMiddleware
def initialize app
@app = app
end
def call env
request = Rack::Request.new(env)
if request.post? && ( request.params['_name'] == 'patch' )
request.set_header 'REQUEST_METHOD', 'PATCH'
View gist:54334bf7f40f8d8e7dda0b9b5430719e
azure storage cors set -a [-beep-] -k [-beep-] --blob --cors "[{\"AllowedOrigins\":\"http://foo.bar.com, http://127.0.0.1:1234\",\"AllowedMethods\":\"GET\",\"MaxAgeInSeconds\":\"86400\",\"AllowedHeaders\":\"*\",\"ExposedHeaders\":\"*\"}]"
@namiwang
namiwang / uploader.sh
Created May 30, 2016
azure blob folder uploader
View uploader.sh
#!/bin/bash
# https://stackoverflow.com/questions/28900078/upload-multi-file-from-linux-folder-to-azure-blob-storage
export AZURE_STORAGE_ACCOUNT='your_account'
export AZURE_STORAGE_ACCESS_KEY='your_access_key'
export container_name='name_of_the_container_to_create'
export source_folder=~/path_to_local_file_to_upload/*
@namiwang
namiwang / ideagen
Created Jun 23, 2013
get random words from matrix67's idea generator
View ideagen
require 'nokogiri'
require 'open-uri'
50.times do
page = Nokogiri::HTML(open("http://www.matrix67.com/ideagen/"))
word = page.css('body .main p').children[0].to_s.gsub("\r",'').gsub("\n",'').gsub("\t",'').split('的')[1]
File.open('words','a'){ |file| file.write(word+"\n") }
end
You can’t perform that action at this time.