Skip to content

Instantly share code, notes, and snippets.

@davepoon
davepoon / gist:3984488
Created October 31, 2012 02:37
Git submodule update command
git submodule -q foreach git pull -q origin master
@davepoon
davepoon / gist:3984681
Created October 31, 2012 03:48
A vim command to save a file in vim or vi without root permission
:w !sudo tee %
@davepoon
davepoon / gist:4220464
Created December 5, 2012 23:24
PHP Regex to get src value
<?php
$input_string = '<script type="text/javascript" src="http://localhost/assets/javascript/system.js" charset="UTF-8"></script>';
$count = preg_match('/src=(["\'])(.*?)\1/', $input_string, $match);
if ($count === FALSE)
echo('not found\n');
else
echo($match[2] . "\n");
$input_string = "<script type='text/javascript' src='http://localhost/index.php?uid=93db46d877df1af2a360fa2b04aabb3c' charset='UTF-8'></script>";
$count = preg_match('/src=(["\'])(.*?)\1/', $input_string, $match);
@davepoon
davepoon / gist:4371622
Created December 25, 2012 04:29
Added the .gitignore, and refresh the file index so the files get ignored properly.
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@davepoon
davepoon / gist:4743527
Created February 9, 2013 02:14
Set the ownership of htdoc to www-data user and group, it's been set to vagrant user and group by default.
config.vm.share_folder("www", "/var/www", "~/www", :owner => "www-data", :group => "www-data")
/*
* Grid Overlay for Twitter Bootstrap
* Assumes a 1.692em baseline grid (22px/13px)
*/
@media (min-width: 1200px) {
body {
background: -webkit-gradient(linear, top left, bottom left, color-stop(0%, rgba(0, 0, 0, 0.05)), color-stop(4.545%, rgba(0, 0, 0, 0.05)), color-stop(4.545%, rgba(0, 0, 0, 0)), color-stop(100%, rgba(0, 0, 0, 0))), -webkit-gradient(linear, top left, top right, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(35%, rgba(0, 0, 0, 0)), color-stop(35%, rgba(0, 0, 0, 0.05)), color-stop(36%, rgba(0, 0, 0, 0.05)), color-stop(36%, rgba(0, 0, 0, 0)), color-stop(65%, rgba(0, 0, 0, 0)), color-stop(65%, rgba(0, 0, 0, 0.05)), color-stop(66%, rgba(0, 0, 0, 0.05)), color-stop(66%, rgba(0, 0, 0, 0)), color-stop(100%, rgba(0, 0, 0, 0))), -webkit-gradient(linear, top left, top right, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(0%, rgba(0, 0, 0, 0.1)), color-stop(0.085%, rgba(0, 0, 0, 0.1)), color-stop(0.085%, rgba(0, 0, 0, 0)));
background: -webkit-linear-gradient(90deg, rgba(0, 0, 0, 0.05), rgba(
@davepoon
davepoon / Delete all the untagged images
Created March 3, 2015 00:58
Delete all the untagged images
docker rmi `docker images -q --filter "dangling=true"`
@davepoon
davepoon / Copy ssh key to clipboard
Created March 3, 2015 05:12
Copy ssh key to clipboard
pbcopy < ~/.ssh/id_rsa.pub
@davepoon
davepoon / Pass props to {this.props.children}
Created May 23, 2016 04:58
Pass props to {this.props.children}
// instead of this.props.children, we use the following syntax to pass props to children components
{React.cloneElement(this.props.children, this.props)}
@davepoon
davepoon / Binding to methods of React class
Created May 25, 2016 01:39
A quick way of binding to methods of React class
constructor() {
for (const methodName of [
'yourMethod1',
'yourMethod2',
'yourMethod3',
]) { this[methodName] = this[methodName].bind(this); }
}