Skip to content

Instantly share code, notes, and snippets.

View melchoy's full-sized avatar
👩‍💻

Melissa Choy melchoy

👩‍💻
View GitHub Profile
@melchoy
melchoy / gist:3878831
Created October 12, 2012 11:44 — forked from superp/gist:888384
Publish stream in Facebook & Twitter with OmniAuth
# models/person.rb
serialize :auth_hash, Hash
def facebook
@fb_user ||= FbGraph::User.me(user_attributes[:token])
end
def twitter
@tw_user ||= prepare_access_token(user_attributes[:token], user_attributes[:secret])
end
@melchoy
melchoy / install_php_ngninx.sh
Created October 23, 2012 02:29 — forked from gagarine/install_php_ngninx.sh
Drupal on php-fpm + nginx + apc
brew update
brew install gmp
#install Nginx
brew install nginx
# copy launch script
cp /usr/local/Cellar/nginx/1.0.12/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
#try to launch Nginx
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
@melchoy
melchoy / gist:4062681
Created November 12, 2012 23:08
WordPress get post data via ajax with json
<?php
// Make ajax requests to /wp-admin/admin-ajax.php?action=get_post&id=127
add_action('wp_ajax_get_post', 'figgis_get_post_json');
add_action('wp_ajax_nopriv_get_post', 'figgis_get_post_json');
function get_post_json() {
header('Cache-Control: no-cache, must-revalidate');
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
http {
# Declare index at http level
index index.html index.php;
server {
# Set IP & Port For Server Block
listen 00.000.000.000:80;
# Set Server Name
server_name www.example.com;
# Redirect WWW to non WWW (http://wiki.nginx.org/Pitfalls)
module ActiveAdminHelper
def admin_arbre_context
@admin_arbre_context ||= Arbre::Context.new(assigns, self)
end
def default_renderer
case controller.send(:resource_class).name
when "ActiveAdmin::Page"
"page"
:: 1) Download srvany.exe from Microsoft Windows 2003 Resource Kit (available free from Microsoft).
:: 2) Copy srvany.exe into the folder where google drive is installed or next to this script file.
:: 3) Run this script as an Administrator
echo off
cls
SET STARTING_DIR=%CD%
SET SCRIPT_DIR=%~dp0
@melchoy
melchoy / install-comodo-ssl-cert-for-nginx.rst
Created December 13, 2015 05:58 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@melchoy
melchoy / gist:6723bb97d9888e73f694
Created December 17, 2015 22:35 — forked from blainerobison/gist:1f1e59c99f5c9a78b93d
wp: Move Category Count Inside Link [WordPress]
/**
* Move Category Post Counts Inside Link
*
* filters wp_list_categories()
*
* @param string $links link html output
* @return string
*/
function prefix_move_category_count( $links ) {
@melchoy
melchoy / ssl_puma.sh
Created January 25, 2017 21:15 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@melchoy
melchoy / routes.md
Created April 12, 2017 04:02 — forked from dideler/routes.md
Rails Routes

A summary of the Rails Guides on Routes, plus other tips.

The Rails router recognizes URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views.

Examples

# Redirects /orders/report to orders#report.
get 'orders/report', to: 'orders#report'