Skip to content

Instantly share code, notes, and snippets.

View dungdt88's full-sized avatar

Richard Dam dungdt88

  • Ho Chi Minh City, Vietnam
View GitHub Profile
@dungdt88
dungdt88 / ssh_with_public_key.sh
Last active March 7, 2016 06:15
SSH with Public Key
# On Client
## Generate Key
ssh-keygen -t rsa {-b 4096}
## Copy identity to remote-host (requires remoteuser's password)
ssh-copy-id -i <path/to/public/key> <remoteuser>@<remotehost>
## or just copy the content of file ~/.ssh/id_rsa.pub on Client to the end of file ~/.ssh/authorized_keys on Server
## SSH
@dungdt88
dungdt88 / gist:bcade6070dd7133a815c
Last active August 29, 2015 14:10
Graph generation with fixed degree
insufficient[degs_, edgelist_, donelist_] := Catch[Module[
{j, k, n = Length[degs], diff},
For[j = 1; j <= n, j++,
If[degs[[j]] == 0, Continue[]];
diff = degs[[j]] - Length[Union[donelist, edgelist[[j]]]];
If[diff <= 0, Throw[True]];
];
False
]]
@dungdt88
dungdt88 / gist:5465626
Last active December 16, 2015 16:49
Convert name to slug
<?php
function name2Slug($name, $separator = '-', $maxLength = 40)
{
$url = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $name);
$url = trim(substr(strtolower($url), 0, $maxLength));
$url = preg_replace('/[^a-z0-9-]/', '-', $url);
$url = preg_replace('/'.$separator.'+/', '-', $url);
return $url;
}
@dungdt88
dungdt88 / setfacl_sample.sh
Last active December 16, 2015 16:49
Share permission between user & apache
setfacl -R -m u:apache:rwX -m u:`whoami`:rwX app/cache app/logs
setfacl -dR -m u:apache:rwx -m u:`whoami`:rwx app/cache app/logs