Skip to content

Instantly share code, notes, and snippets.

View and1truong's full-sized avatar
🎯

Hong Truong and1truong

🎯
View GitHub Profile
@and1truong
and1truong / .travis.yml
Created August 14, 2015 06:45
[TEMP, NOT WORKING] Drupal .travis.yml file
language: php
php:
- 5.5
- 5.4
matrix:
fast_finish: true
mysql:
database: drupal
@and1truong
and1truong / 000-example.php
Last active August 29, 2015 14:25
#silex #module
<?php
$app = new App();
$app->registerModule(new UserModule());
$app->run();
#!/usr/bin/perl
use IO::Socket::INET;
use Carp;
my $ip='192.168.1.222';
my $ipport='5200';
my $serialport='COM4'; # for windows
my $serial='/dev/ttyUSB0'; #for linux
my $baudrate='38400';
@and1truong
and1truong / 01-UserLoginEvent.php
Last active August 29, 2015 14:16
Event dispatcher
<?php
/**
* Step 01: Define event
*/
class UserLoginEvent extends Symfony\Component\EventDispatcher\Event {
private $user;
public function __construct($user) {
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "VPC knowhow template",
"Parameters": {
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type": "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern": "[-_ a-zA-Z0-9]*",
# REGULAR VERSION
gunzip -c db.sql.gz | grep -Ev "^INSERT INTO \`(cache_|search_|sessions|whatever)" | mysql -u root -p databasename
# DRUPAL VERSION
gunzip -c db.sql.gz | grep -Ev "^INSERT INTO \`(cache_|search_|sessions|whatever)" | drush sqlc
<?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>',
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')
#!/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
#!/bin/sh
:<<'=cut'
=head1 NAME
git-wrapper - avoid committing as you@invalid
=head1 SYNOPSIS