Skip to content

Instantly share code, notes, and snippets.

View v9n's full-sized avatar
🛫
forward email at mailwip.com

Vinh v9n

🛫
forward email at mailwip.com
View GitHub Profile
@v9n
v9n / remove_deleted_file_from_git.sh
Created June 15, 2012 20:45
Remove deleted file from git and commit it
git ls-files --deleted | xargs git rm
git commit
@v9n
v9n / sample.php
Created August 17, 2012 07:35
sample.php
public static function send($to, $from, $subject, $message, $html = FALSE, $attach_file=NULL)
{
// Connect to SwiftMailer
(Email::$mail === NULL) and email::connect();
// Determine the message type
$html = ($html === TRUE) ? 'text/html' : 'text/plain';
// Create the message
$message = Swift_Message::newInstance($subject, $message, $html, 'utf-8');
@v9n
v9n / get_document_dir.m
Created August 29, 2012 20:44
Get document dir of an iOS applicationm
// In each app we have this folder layout:
// Appplications/57C5BD59-C5BF-410C-BAA3-4F09A80F760F/Documents/
NSArray *paths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
@v9n
v9n / get_file_attb.m
Created August 29, 2012 20:46
Get file attributes
NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:filePath traverseLink:YES];
if(fileAttributes != nil)
{
NSString *fileSize = [fileAttributes objectForKey:NSFileSize];
[[cell detailTextLabel] setText:[NSString stringWithFormat:@\"%@ kb\", fileSize]];
NSLog(@\"File size: %@ kb\", fileSize);
}
@v9n
v9n / job.markdown
Created August 31, 2012 23:12
Join Axcoto

The Company

Axcoto is currently a small, one man web development company. I develop WordPress plugins and some small applications to help people have a better life ;). We currently need 1 designer and 1 developer.

The Task

Basically, you have 2 tasks:

  • Work on products of Axcoto: WillingApp and custom WordPress plugin, theme.
  • Work on your own ideas. Whatever you want, even contribute to open source project.
@v9n
v9n / sed_recurisive_replace.sh
Created September 10, 2012 17:44
Recursive replace content in file
find . -type f -exec sed -i sedbak 's/for/bar/g' {} \; #replace file and made a backup with extension sedbak
find . -name '*sedbak' -exec rm -rf {} \; #if everything is fine, remove all back up file
@v9n
v9n / kill_with_pid_awk_sed.sh
Created September 12, 2012 18:36
Kill a procees with pid getting on the fly via awk
#For example, we want to kill Netbeans
ps -ef | grep beans | awk ' $6 != "ttys000" {print$2;}' | xargs kill {}
#Or get the first line only (to aovid getting grep command itself)
ps -ef | grep beans | head -n 1 | awk ' {print$2}' | xargs kill {}
@v9n
v9n / swap.php
Created September 18, 2012 16:26
swap value of 2 vars without using any extra var
<?php
$a = 1;
$b = 2;
list($a, $b) = array($b, $a);
print "a=$a, b=$b\n";
@v9n
v9n / tableview.java
Created September 19, 2012 22:47
Table Stuff in Android
TableRow tr = new TableRow(this);
TableLayout.LayoutParams tableRowParams=
new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
int leftMargin=10;
int topMargin=2;
int rightMargin=10;
int bottomMargin=2;
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.