Skip to content

Instantly share code, notes, and snippets.

View darklight721's full-sized avatar
👨‍💻

Roy Evan Sia darklight721

👨‍💻
  • Cebu City, Philippines
  • X @pr00t
View GitHub Profile
@darklight721
darklight721 / package.json
Created August 29, 2015 09:06
Sample webpack config with promise/fetch shimming
{
"name": "SampleWebpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"webpack": "./node_modules/.bin/webpack",
"bundle": "npm run webpack -- -p",
"start": "npm run webpack -- -d --watch"
},
@darklight721
darklight721 / jquery.tablesorter.js
Last active August 29, 2015 14:10
A jQuery tablesorter plugin
/*
* jquery.tablesorter.js - a small table sorter jquery plugin
* Usage:
* $('table').tablesorter();
* Options:
* $('table').tablesorter({
* defaultSort: [0, 1] // initial sort - [<column index>, <1 (ascending) || -1 (descending)>]
* });
* Action Triggers:
* $('table').trigger('update'); // to update the table when there are changes like addition/removal of <tr>/<td>
@darklight721
darklight721 / init.coffee
Created December 30, 2014 02:55
Atom command to terminate line with a semicolon
atom.commands.add 'atom-text-editor',
'easy-semicolon:end-line': (event) ->
editor = @getModel()
editor.moveToEndOfLine()
editor.insertText(';')
@darklight721
darklight721 / .bash_profile
Last active August 29, 2015 14:21
My bash profile
export PS1="\[\e[1;34m\]\u@\h\[\e[0m\]:\[\e[1;36m\]\W\[\e[0m\]$ "
alias ll="ls -ahlFG"
alias rmd="rm -rf"
alias fsize="stat -f%z"
alias finder="open -a Finder ./"
mcd() { mkdir "$1" && cd "$1"; }
gitr() {
function add(...n) {
let t = n.reduce((a, b) => a + b);
let a = add.bind(0, t);
a.valueOf = () => t;
return a;
}
{
"parser": "babel-eslint",
"rules": {
// best practices
"curly": [2, "multi-line"],
"dot-notation": 2,
"dot-location": [2, "property"],
"eqeqeq": [2, "allow-null"],
"guard-for-in": 2,
"no-caller": 2,
# Motion commands
h - move left
j - move down
k - move up
l - move right
w - move to next word
b - move to beginning of word
e - move to end of word
@darklight721
darklight721 / sort1.c
Last active December 12, 2015 09:39
Insertion Sort in C using array and linked list. I'm pretty sure my implementation in linked list isn't the most efficient.
void insertion_sort(int list[], int size)
{
int i, j, insertVal;
for (i = 1; i < size; i++) {
insertVal = list[i];
for (j = i; j > 0 && insertVal < list[j - 1]; j--) {
list[j] = list[j - 1];
}
list[j] = insertVal;
#include <stdio.h>
#include <stdlib.h>
int ** makeGrid(int size, int *startX, int *startY, int *endX, int *endY)
{
// allocate memory for the grid
int **grid = (int**)malloc(sizeof(int*) * size);
int x, y;
for (x = 0; x < size; x++) {
grid[x] = (int*)malloc(sizeof(int) * size);
@darklight721
darklight721 / quicksort.c
Last active December 12, 2015 10:39
Quicksort implementation in C.
void quick_sort(int list[], int left, int right)
{
if (left < right) {
int pivot = (left + right) / 2; // left + (right - left) / 2 is safer to use for large lists
pivot = partition(list, left, right, pivot);
quick_sort(list, left, pivot - 1);
quick_sort(list, pivot + 1, right);
}
}