Skip to content

Instantly share code, notes, and snippets.

@karmiphuc
karmiphuc / disableDevTools.html
Created May 29, 2014 10:09
Disable DevTools and console.log()
<script type="text/javascript">
if (window.webkitURL) {
var ish, _call = Function.prototype.call;
Function.prototype.call = function () { //Could be wrapped in a setter for _commandLineAPI, to redefine only when the user started typing.
if (arguments.length > 0 && this.name === "evaluate" && arguments [0].constructor.name === "InjectedScriptHost") { //If thisArg is the evaluate function and the arg0 is the ISH
ish = arguments[0];
ish.evaluate = function (e) { //Redefine the evaluation behaviour
throw new Error ('Rejected evaluation of: \n\'' + e.split ('\n').slice(1,-1).join ("\n") + '\'');
};
Function.prototype.call = _call; //Reset the Function.prototype.call
@karmiphuc
karmiphuc / autoVer.php
Last active August 29, 2015 14:01
Step 6/9: Bust that Cache Wide Open! If you have read the configuration files for NGINX, you will have noticed some lines about a cache-buster for CSS and JS files. What it does is altering the link to your theme’s unified stylesheet and JS to something like style.1352707822.css, in which the number is the filemtime. So whenever you alter your f…
<?php
/**
* Automated cache-buster function via filemtime
**/
function autoVer($url){
$name = explode('.', $url);
$lastext = array_pop($name);
array_push(
$name,
filemtime($_SERVER['DOCUMENT_ROOT'] . parse_url($url, PHP_URL_PATH)),
@karmiphuc
karmiphuc / fbFanpageMassInvite.js
Last active October 24, 2015 19:20
Rogue script fixed. Facebook Fanpage auto invite script now works fine.
javascript: var Title = "LIkeeeeeeeeeeeeeeeee </A>";
var Descriptions = "",
_text = '';
page_id = /"profile_owner":"([0-9]+)"/.exec(document.getElementById("pagelet_timeline_main_column").getAttribute("data-gt"))[1];
function InviteFriends(opo) {
jx.load(window.location.protocol + "//www.facebook.com/ajax/pages/invite/send_single?page_id=" + page_id + "&invitee=" + opo + "&elem_id=u_0_1k&action=send&__user=" + user_id + "&__a=1&__dyn=7n8aD5z5CF-3ui&__req=8&fb_dtsg=" + fb_dtsg + "&phstamp=", function (a) {
var b = a.substring(a.indexOf("{"));
var c = JSON.parse(b);
i--;
@karmiphuc
karmiphuc / Notepad-Plus-Plus.tmTheme
Last active August 29, 2015 13:56
My SublimeText 3 setting
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Notepad-Plus-Plus</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@karmiphuc
karmiphuc / sampleHTML5.html
Created January 26, 2014 11:36
HTML5 Template
<html lang="vi">
<head>
<meta charset="UTF-8" />
<title>Test | KarmiPhuc</title>
<!-- đặt CSS ở thẻ head -->
<link...>
</head>
<body>
<!-- HTML here ...-->
<!-- đặt JS trước khi đóng body -->
@karmiphuc
karmiphuc / script.js
Last active January 4, 2016 13:49
Test js async
document.getElementById('second').innerHTML = 'And this is Javascript';
@karmiphuc
karmiphuc / urlParsing.js
Created January 20, 2014 08:05
URL Parsing from text
String.prototype.parseURL = function() {
return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g, function(url) {
return url.link(url);
});
};
String.prototype.parsePseudoURL = function() {
return this.replace(/(^| )([^\/])((www|[^\/\. ]+)\.[\S]+(\b|$|))/gim, '$1<a href="http://$2$3" target="_blank">$2$3</a>');
};
@karmiphuc
karmiphuc / urlParsing.php
Last active January 3, 2016 20:39
URL Parsing from text
<?
function parseUrl($s) {
$__ = preg_replace('/([A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+)/i', '<a href="$1" target="_blank">$1</a>', $s);
return preg_replace('/(^| )([^\/])((www|[^\/\. ]+)\.[A-Za-z]+(\b|$|))/i', '$1<a href="http://$2$3" target="_blank">$2$3</a>', $__);
};
$s = 'Tinhte.vn asdasd google.com asdjaskdjajks www.abc.com xxx Google http://google.com.vm/search/asdajs.html';
var_dump(parseUrl($s));

Setup

git clone <repo>

clone the repository specified by ; this is similar to "checkout" in some other version control systems such as Subversion and CVS

Add colors to your ~/.gitconfig file: