Skip to content

Instantly share code, notes, and snippets.

View and1truong's full-sized avatar
🎯

Hong Truong and1truong

🎯
View GitHub Profile
@and1truong
and1truong / README.md
Created July 26, 2012 03:51 — forked from mbostock/.block
Epicyclic Gearing

From Wikipedia: Epicyclic gearing or planetary gearing is a gear system consisting of one or more outer gears, or planet gears, revolving about a central, or sun gear. … Epicyclic gearing systems also incorporate the use of an outer ring gear or annulus, which meshes with the planet gears.

Built with D3.js.

@and1truong
and1truong / gist:3871613
Created October 11, 2012 10:54 — forked from drushman/gist:3871535
Update BrainTree Checkout Workflow 11/10/2012

Purchase and Checkout Workflow: Done

RAW Transaction Logs

  1. I created schema for tables to save log instead use watchdog.
  2. I log RAW Requests and RAW Responses sent and received from BrainTree (until test yet done)
@and1truong
and1truong / gist:4116628
Created November 20, 2012 07:47 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@and1truong
and1truong / gist:4373637
Last active December 10, 2015 03:18 — forked from drushman/gist:3792605
Bellow is the example for dynamically creating/deleting/modifying field-collection item for any node.
Suppose 'field_page_collection1' is the field collection for the 'page' content type having two text fields 'field_page_collection1_text1', 'field_page_collection1_text2'.
To attach or create field-collection item for node having node id 1.
<?php
$node = node_load(1);
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_page_collection1')); // Create new field collection item.
$field_collection_item->setHostEntity('node', $node); // Attach it to the node.
http://drupal.org/project/abstract - 198 users
http://drupal.org/project/class - 0 users
http://drupal.org/project/clone - 0 users
http://drupal.org/project/do - 4 users
http://drupal.org/project/echo - 853 users
http://drupal.org/project/goto - 0 users
http://drupal.org/project/include - 738 users
http://drupal.org/project/interface - 95 users
http://drupal.org/project/list - 0 users
http://drupal.org/project/or - 0 users
#!/bin/bash
# WebSocket shell, start & browse to http://<Host>:6655/
# Requires bash 4.x, openssl.
# Author: rootshell@corelogics.de (which isn't me, apk)
coproc d { nc -l -p 6656 -q 0; }
nc -l -p 6655 -q 1 > /dev/null <<-ENDOFPAGE
HTTP/1.1 200 OK
<html><head><script language="javascript">
var url = location.hostname + ':' + (parseInt(location.port) + 1);
#!/bin/sh
:<<'=cut'
=head1 NAME
git-wrapper - avoid committing as you@invalid
=head1 SYNOPSIS
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
import json
import os
import requests
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
if GITHUB_TOKEN is None:
raise Exception('Missing GITHUB_TOKEN from os.environ')
<?php
/**
* Regex taken from http://saturnboy.com/2010/02/parsing-twitter-with-regexp/
*/
function parse_tweet($text) {
// Parse links.
$text = preg_replace(
'@(https?://([-\w\.]+)+(/([\w/_\.]*(\?\S+)?(#\S+)?)?)?)@',
'<a href="$1">$1</a>',