Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Hello, mister!

Krisan Alfa Timur krisanalfa

:octocat:
Hello, mister!
View GitHub Profile
@krisanalfa
krisanalfa / autolike.js
Created Mar 4, 2013
Simulate Auto-Like Facebook Status
View autolike.js
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 Dec 15, 2015
Simple statefull iptables rules
View 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 Dec 15, 2015
Array, variable protoyping, and function in C++
View alfangelalfa.cpp
#include <cstdlib>
#include <iostream>
using namespace std;
int mahasiswa [10] = {
2009140507,
2009140508,
1234567890
};
@krisanalfa
krisanalfa / loveangel.cpp
Created Apr 14, 2013
Print love in c++ using two methods
View loveangel.cpp
#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 Dec 16, 2015
Put it on "~/.config/sublime-text-2/Packages/User/" folder. Create an HTML document (by extension or by syntax), and type "html5" -> TAB.
View HTML5.sublime-snippet
<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
Find out if you are using the latest stable kernel from kernel.org or not
View are_you_updated.sh
#!/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
Share Many on Social Network
View share.html
<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>
View SublimeTextInstaller.sh
#!/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 Dec 18, 2015
My Sublime Text 2 Config
View Preferences.sublime-settings
{
"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 Jun 7, 2013
Post your 'commit message' and your 'commit url' to Twitter when you push your code to GitHub.
View GitPostToTwitter.sh
#!/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