Skip to content

Instantly share code, notes, and snippets.

View rc1021's full-sized avatar
🏠
Working from home

許益銘 rc1021

🏠
Working from home
View GitHub Profile
@dira
dira / omniauth.rb
Created December 1, 2010 01:56
OmniAuth strategy for a custom provider
# config/initializers/omniauth.rb
module OmniAuth
module Strategies
# tell OmniAuth to load our strategy
autoload :Pixelation, 'lib/pixelation_strategy'
end
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, "app_name", "secret"
@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@taf2
taf2 / media_uploader.js
Created June 7, 2011 16:43
MultiPart Form POST - Compatible with Uploading Files to S3
Ti.include("/lib/strftime.js");
// see: http://blog.odonnell.nu/posts/streaming-uploads-s3-python-and-poster/
function MediaLoader(user) {
this.user = user;
}
MediaLoader.prototype = {
// upload a file with some postData fields
//
// multipartUpload(host, port, "your_file_name", fileObject, [['field1','value'], ['field2','value']], function(p) { });
@ziadoz
ziadoz / awesome-php.md
Last active May 10, 2024 15:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@hemanth
hemanth / js-best-practices.md
Created March 14, 2012 10:33 — forked from TheJase-Gist/js-best-practices.md
JavaScript best practices

JavaScript Best Practices

Code conventions

Closing/opening brackets

Although this isn't a problem in other languages, because of semicolon insertion, there could be problems if you don't place the bracket on the opening line:

// no:
function()
{
@betweenbrain
betweenbrain / gist:2284129
Created April 2, 2012 14:56
Git command to export only changed files between two commits
git archive --output=file.zip HEAD $(git diff --name-only SHA1 SHA2)
@xdite
xdite / gist:3106785
Created July 13, 2012 19:15
Speedup Rails Asset Pipeline precompile process
@vyspiansky
vyspiansky / build-tree.php
Last active October 2, 2023 14:36
PHP: convert object / array to tree structure
<?php
/**
* The below functions take the single level array of items as an argument
* and turn it into a multidimensional array structure (tree),
* where each item has an array of sub-items.
*
* Each item should have at least an `id` and `parent_id`,
* where the `parent_id` is `0` if it's top level.
*
* Source: http://goo.gl/p2GybZ
@pkuczynski
pkuczynski / parse_yaml.sh
Last active May 25, 2024 15:21
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@rajivseelam
rajivseelam / A.README
Last active June 7, 2017 06:15
Create Google Alert and grab the feed.
Google alerts is a way to manage your content by subscribing to keywords. Here is an example on how to make that google alert with php.
Get the feed url and parse the feed. There won't be any feed available as soon the alert is created.
-------------------------------------
Copy composer.json and do composer update.
Add this to providers