Skip to content

Instantly share code, notes, and snippets.

@OscarGalindo
OscarGalindo / index.html
Created April 15, 2015 11:19
Tree view in angularjs
<!doctype html>
<html ng-app="ctz">
<head>
<title>CategoryTree</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script>
angular.module('treeApp', []);
angular.module('treeApp').controller('treeCtrl', treeCtrl);
treeCtrl.$inject = ['$scope', '$http'];
@OscarGalindo
OscarGalindo / csv_to_es_bulk.py
Created April 24, 2015 10:36
CSV to Elasticsearch Bulk Data
import pyelasticsearch as pyes
import csv
URL_ES = 'http://localhost:9200/'
CSV_FILE = 'example.csv'
INDEX = 'Index'
TYPE = 'Type'
ID_FIELD = 'id'
f = open(CSV_FILE)
@OscarGalindo
OscarGalindo / snail.py
Last active October 25, 2023 11:51
Snail kata in Python @ Codewars
def snail(array):
results = []
while len(array) > 0:
# go right
results += array[0]
del array[0]
if len(array) > 0:
# go down
for i in array:
@OscarGalindo
OscarGalindo / arraydiff.py
Created May 15, 2015 13:00
Array.diff @ Codewars
array_diff = lambda y,x: [i for i in y if i not in x]
@OscarGalindo
OscarGalindo / vhost
Created May 27, 2015 07:49
Dynamic vhost to nginx
server {
index index.html index.htm index.php;
set $basepath "/var/www";
set $domain $host;
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";
set $servername "${domain}.dev";
}
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@OscarGalindo
OscarGalindo / Terminator.md
Created July 25, 2015 20:23
Shortcuts for terminator

Terminator Shortcuts

  • Ctrl - Shift - E - Split vertically
  • Ctrl - Shift - O - Split horizontally
  • Ctrl - Shift - P - Focus next view
  • Ctrl - Shift - N - Focus previous view
  • Ctrl - Shift - W - Close focused view
  • Ctrl - Shift - Q - Exit terminator
  • Ctrl - Shift - X - Enlarge active view
@OscarGalindo
OscarGalindo / FileUpload.php
Created January 27, 2016 15:24
Unit testing is_uploaded_file and move_uploaded_file
<?php
class FileUpload
{
private $from;
private $destination;
public function __construct($file, $id, $destination = '/tmp', $validExtensions = array())
{
if (!is_array($file) || empty($file['tmp_name']) || !$file['tmp_name']) {
@OscarGalindo
OscarGalindo / ultimate-ut-cheat-sheet.md
Created February 10, 2016 21:24 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@OscarGalindo
OscarGalindo / nextTick.js
Created February 21, 2016 21:14 — forked from mmalecki/nextTick.js
process.nextTick vs setTimeout(fn, 0)
for (var i = 0; i < 1024 * 1024; i++) {
process.nextTick(function () { Math.sqrt(i) } )
}