Skip to content

Instantly share code, notes, and snippets.

View tungd's full-sized avatar
🐳
Back to normal

Tung Dao tungd

🐳
Back to normal
View GitHub Profile
/**
* Mootool Popup
* @author Tung Dao <[email protected]>
*/
;(function(exports) {
var Popup = new Class({
initialize: function(selector) {
this.elements = $$(selector);
@tungd
tungd / twitter.user.js
Created May 15, 2012 06:13
Quick view the first link in twitter
// ==UserScript==
// @match http://twitter.com/*
// @match http://www.twitter.com/*
// @match https://twitter.com/*
// @match https://www.twitter.com/*
// ==/UserScript==
/*!
* Name: Twitter Quick View
* URL: http://tungdao.com
* Description: Add `v` keyboard shortcut to open the first link in a tweet
@tungd
tungd / .vimrc
Created June 9, 2012 17:31
UltiSnip <tab> everything
" UtilSnips
" The <tab> key works as follow
" - if there is popup: <c-n> (next popup item)
" - if there is something behind cursor
" - try expand snippet
" - if can't expand, try jump
" - finally try <c-n> (key word completion)
" The <s-tab>:
" - if there is popup: <c-p> (previous popup item)
" - try jump back
http://www.linuxquestions.org/questions/linux-desktop-74/awesome-wm-3-4-1-help-810852/
audience unsettings jupiter oracle-java7-installer fuse-exfat awesome awesome-extra
ctags vim-gtk git-core
repos:
ppa:audience-members/ppa
ppa:diesch/testing
<div class="intro-hapham">
<img class="img-intro" src="<?php echo bloginfo("template_directory"). get_post_meta($post->ID,"thumbnail_big",true) ?>" border="0" alt="<?php the_title() ?>" />
<div class="text-intro">
<h1 class="title-intro"><?php the_title() ?></h1>
<div class="bor-gra" style="width: 930px; margin:0px auto; height: 1px; background: #999999; "></div>
<div class="cont-intro">
<div class="cols">
<?php the_content(" ") ;?>
@tungd
tungd / Makefile
Created February 19, 2013 09:51
Makefile I used when learning Rust (following this tutorial: http://www.rustforrubyists.com/). Compile and run by `make [example name]/run` Compile and run as test by `make [example name]/test`
RM := rm -vf
TARGET := $(shell find . -type f -not -name "*.rs" -and -not -name "Makefile" -and -not -name ".git")
all:
@echo "Nothing to be done here"
%/run: %.rs
rustc $*.rs
./$*
@tungd
tungd / AndroidManifest.xml
Created March 10, 2013 03:17
Sample XML processing.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stockrobot"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
diff --git a/mail.php b/mail.php
index fbc1b00..2677337 100644
--- a/mail.php
+++ b/mail.php
@@ -7,9 +7,10 @@ while (!file_exists($wp_include) && $i++ < 10) {
}
require($wp_include);
- $name = iconv("UTF-8", "ISO-8859-2", $_POST['name']);
- $email = iconv("UTF-8", "ISO-8859-2", $_POST['email']);
@tungd
tungd / Gemfile
Last active December 18, 2015 15:18
source "https://rubygems.org"
gem "sinatra"
gem "puma"
@tungd
tungd / import.rake
Last active December 18, 2015 17:39
Much faster (~x300) master data import for Rails
def create_master model_class, &block
return unless block_given?
csv = "#{Rails.root}/db/masters/#{model_class.name.split('::').last.underscore}.csv"
model_class.destroy_all
model_class.create! CSV.open(csv).map(&block)
end
def import_master_unsafe model_class, &block
return unless block_given?