Skip to content

Instantly share code, notes, and snippets.

View dinhkhanh's full-sized avatar

Tran Dinh Khanh dinhkhanh

View GitHub Profile
@dinhkhanh
dinhkhanh / git-remove-merged-branches.sh
Created December 20, 2016 15:54
Git remove merged branches
git branch -a --merged remotes/origin/master | grep -v master | grep "remotes/origin/" | cut -d "/" -f 3 | xargs -n 1 git push --delete origin
@dinhkhanh
dinhkhanh / khoeplus.vn.html
Created November 25, 2016 17:01
khoeplus.vn.html
<!DOCTYPE html>
<html>
<head>
<title>A potentially dangerous Request.Form value was detected from the client (------WebKitFormBoundaryd41CkwlF45xatPIB<br>Content-Disposition: form-data; name="...ntent"<br><br><p>Tối 23/11, huấn l...").</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
@dinhkhanh
dinhkhanh / MenuBuilder.php
Created August 8, 2016 07:33 — forked from cklm/MenuBuilder.php
Custom KnpMenuBundle navigation bar twig template to support Font Awesome icons & Twitter bootstrap lay-out
<?php
namespace Acme\HelloBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class MenuBuilder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
@dinhkhanh
dinhkhanh / grep-backdoor.sh
Last active July 19, 2016 16:39
Search backdoor (malicious codes) in directories
#bin/bash
grep -RPn "(passthru|shell_exec|system|phpinfo|base64_decode|chmod|mkdir|fopen|fclose|readfile|php_uname|eval|tcpflood|udpflood|edoced_46esab) *\(" /path/to/source/dir/
@dinhkhanh
dinhkhanh / urlrewrite.php
Created March 18, 2016 08:05 — forked from byjujohn/urlrewrite.php
Magento: Programatically add custom URL Rewriting
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
ini_set('memory_limit', '32M');
set_time_limit (0);
require_once MAGENTO . '/app/Mage.php';
Mage::app();
Mage::getModel('core/url_rewrite')->setIsSystem(0)->setOptions('RP')->setIdPath('Imported-Old-Website-URL-test1')->setTargetPath('alicia-suspender-skirt-32360')->setRequestPath('SHOPONLINE.aspx?Product=Alicia Skirt&amp;Brand=Lascivious Test&amp;PID=1975')->save();
Mage::getModel('core/url_rewrite')->setIsSystem(0)->setOptions('RP')->setIdPath('Imported-Old-Website-URL-test2')->setTargetPath('alicia-suspender-skirt-32360')->setRequestPath('SHOPONLINE.aspx?Product=Alicia Skirt&Brand=Lascivious Test&PID=1975')->save();

Mac OS X LEMP Configuration

This Gist is a collection of configuration files that can be used to easily setup a Homebrew-based LEMP stack on Mac OS X.

Files in this repository are numbered and named for ordering purposes only. At the top of each file is a section of metadata that denote what component the file belongs to and the default name & location of the file. Feel free to implement it however you want.

Note: some configuration files have hard-coded paths to my user directory -- fix it for your setup

Nginx

@dinhkhanh
dinhkhanh / backup.sh
Last active August 29, 2015 14:24
Command line to Backup directories
# For full scenario: https://help.ubuntu.com/community/BackupYourSystem/TAR
# to backup
tar -cvpzf /path/to/save/file/backup.tar.gz --exclude=/path/to/exclude/one --exclude=/path/to/exclude/two/etc --one-file-system /path/is/backed/up
# to restore
sudo tar -xvpzf /path/to/backup.tar.gz -C /path/to/write/files/to --numeric-owner
@dinhkhanh
dinhkhanh / .gitignore
Created July 2, 2015 14:51
Gitignore
app/etc/local.xml
**/.sass-cache/
var/
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
@dinhkhanh
dinhkhanh / add-transaction-detail.php
Created June 13, 2015 09:57
Add Transaction Detail
<?php
$payment->getTransaction($id)
->setAdditionalInformation(
Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
$data
)->save();
<?php
Mage::app()
->getLocale()
->date(strtotime('now'), null, null, false)
->toString('H:m:s');
// distinguish 'm' in PHP and in Magento (month vs minute)