Skip to content

Instantly share code, notes, and snippets.

View krisanalfa's full-sized avatar

Krisan Timur krisanalfa

  • Denpasar, Bali
View GitHub Profile
@krisanalfa
krisanalfa / autolike.js
Created March 4, 2013 14:39
Simulate Auto-Like Facebook Status
function simulate(element, eventName) {
var options = extend(defaultOptions, arguments[2] || {});
var oEvent, eventType = null;
for (var name in eventMatchers) {
if (eventMatchers[name].test(eventName)) { eventType = name; break; }
}
if (!eventType) throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');
if (document.createEvent) {
oEvent = document.createEvent(eventType);
if (eventType == 'HTMLEvents') {
@krisanalfa
krisanalfa / iptables.rules
Last active December 15, 2015 20:40
Simple statefull iptables rules
# Generated by iptables-save v1.4.18 on Mon Apr 8 10:23:34 2013
*nat
:PREROUTING ACCEPT [44:10632]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [8:570]
:POSTROUTING ACCEPT [4:266]
-A PREROUTING -i ppp0 -p tcp -m tcp --dport 22 -j DNAT --to-destination 192.168.1.1
-A PREROUTING -i ppp0 -p tcp -m tcp --dport 8000 -j DNAT --to-destination 192.168.1.1:80
-A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE
-A POSTROUTING -s 10.0.0.0/16 -o ppp0 -j MASQUERADE
@krisanalfa
krisanalfa / alfangelalfa.cpp
Last active December 15, 2015 22:39
Array, variable protoyping, and function in C++
#include <cstdlib>
#include <iostream>
using namespace std;
int mahasiswa [10] = {
2009140507,
2009140508,
1234567890
};
@krisanalfa
krisanalfa / loveangel.cpp
Created April 14, 2013 03:45
Print love in c++ using two methods
#include <cstdlib>
#include <iostream>
using namespace std;
void love(int baris) {
if (baris == 1) {
cout << ",d88b.d88b," << endl;
} else if (baris == 2) {
cout << "88888888888" << endl;
@krisanalfa
krisanalfa / HTML5.sublime-snippet
Last active December 16, 2015 14:39
Put it on "~/.config/sublime-text-2/Packages/User/" folder. Create an HTML document (by extension or by syntax), and type "html5" -> TAB.
<snippet>
<content><![CDATA[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js" lang="en"> <![endif]-->
<html>
<head>
@krisanalfa
krisanalfa / are_you_updated.sh
Created May 13, 2013 06:58
Find out if you are using the latest stable kernel from kernel.org or not
#!/usr/bin/env bash
latest=$(curl https://www.kernel.org/ -s | sed -n "/<td id=\"latest_link\">/,/<\/td>/p" | sed -n -e 's/.*<a.*>\(.*\)<\/a>.*/\1/p');
yours=$(uname -r | sed 's/-.*$//g');
if [[ $latest == "" ]]; then
echo "Please connect to internet"
else
if [[ $latest == $yours ]]; then
echo "You are updated!"
@krisanalfa
krisanalfa / share.html
Created May 16, 2013 08:51
Share Many on Social Network
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<div class="g-plusone" data-size="standard" data-annotation="none" data-href="http://double-dragon.blogspot.com"></div>
<a href="https://twitter.com/intent/tweet?text=I love Twitter development&related=krisanalfa&via=krisanalfa">Tweet</a>
<a href="http://www.facebook.com/sharer.php?s=100&p[title]=Krisan Alfa&p[summary]=I love programming&p[url]=https:twitter.com/krisanalfa&p[images][0]https://si0.twimg.com/profile_images/3649058380/70ffa157f05c25c5b87e52cd07a7149e.png" target="_blank">Facebook</a>
#!/bin/bash
# Variable
arch=$(uname -m)
url32="http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.1.tar.bz2"
url64="http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.1%20x64.tar.bz2"
extractOutput=
# Function
cin() {
@krisanalfa
krisanalfa / Preferences.sublime-settings
Last active December 18, 2015 04:49
My Sublime Text 2 Config
{
"caret_style": "phase",
"draw_white_space": "none",
"ensure_newline_at_eof_on_save": true,
"font_face": "Ubuntu Mono",
"font_size": 17,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
@krisanalfa
krisanalfa / GitPostToTwitter.sh
Created June 7, 2013 08:51
Post your 'commit message' and your 'commit url' to Twitter when you push your code to GitHub.
#!/usr/bin/env bash
# File name: GitPostToTwitter
# Author: Krisan Alfa Timur
command -v twidge > /dev/null
if [[ -d .git ]]; then
if [[ $? -eq 0 ]]; then
read_git_hub=$(cat .git/config | grep github);
if [[ $read_git_hub == "" ]]; then