Skip to content

Instantly share code, notes, and snippets.

View ismaels's full-sized avatar

Ismael Stahelin ismaels

  • Brasil
View GitHub Profile
@ismaels
ismaels / countries.json
Last active February 19, 2024 22:00
Test Data
{"AD":{"name":"Andorra","native":"Andorra","phone":[376],"continent":"EU","capital":"Andorra la Vella","currency":["EUR"],"languages":["ca"]},"AE":{"name":"United Arab Emirates","native":"دولة الإمارات العربية المتحدة","phone":[971],"continent":"AS","capital":"Abu Dhabi","currency":["AED"],"languages":["ar"]},"AF":{"name":"Afghanistan","native":"افغانستان","phone":[93],"continent":"AS","capital":"Kabul","currency":["AFN"],"languages":["ps","uz","tk"]},"AG":{"name":"Antigua and Barbuda","native":"Antigua and Barbuda","phone":[1268],"continent":"NA","capital":"Saint John's","currency":["XCD"],"languages":["en"]},"AI":{"name":"Anguilla","native":"Anguilla","phone":[1264],"continent":"NA","capital":"The Valley","currency":["XCD"],"languages":["en"]},"AL":{"name":"Albania","native":"Shqipëria","phone":[355],"continent":"EU","capital":"Tirana","currency":["ALL"],"languages":["sq"]},"AM":{"name":"Armenia","native":"Հայաստան","phone":[374],"continent":"AS","capital":"Yerevan","currency":["AMD"],"languages":["hy","ru"
@ismaels
ismaels / list-github-org-repos.py
Created June 17, 2020 17:23 — forked from tilayealemu/list-github-org-repos.py
List organization's repos, last commit date to master and committer
# Script to fetch all repos under a git organization
# Returns last committer to master and date of commit
# Results sorted by commit date
# Replace ORG_NAME, USERNAME, and PASSWORD variables
import urllib2
import requests
import json
ORG_NAME = 'my-org'
<?php
function getNextLotteryDay($dateAsString=null) {
$date = isset($dateAsString) ? new DateTime($dateAsString) : new DateTime();
$weekDay = $date->format('w');
$days = $weekDay < 3 ? 3 - $weekDay : 6 - $weekDay;
$date->add(new DateInterval("P${days}D"));
echo $date->format('Y-m-d');
}
@ismaels
ismaels / install_mysql.sh
Created September 25, 2017 20:57 — forked from rrosiek/install_mysql.sh
Vagrant provision script for php, Apache, MySQL, phpMyAdmin, Laravel, and javascript helpers. Tested with Ubuntu 16.04.
#! /usr/bin/env bash
###
#
# install_mysql.sh
#
# This script assumes your Vagrantfile has been configured to map the root of
# your application to /vagrant and that your web root is the "public" folder
# (Laravel standard). Standard and error output is sent to
# /vagrant/vm_build.log during provisioning.
@ismaels
ismaels / compare_folders.rb
Last active February 3, 2018 17:45
Compare the contents of two folders
#!/usr/bin/env ruby
# encoding: utf-8
require 'fileutils'
errors = []
folderA = 'folder1'
folderB = 'folder2'
# list all files in each folder
@ismaels
ismaels / proxy.js
Last active October 20, 2015 22:15
Creates a http proxy server used as a router for two app instances running on different ports
var http = require('http'),
httpProxy = require('http-proxy');
// Create a proxy server with custom application logic
var proxy = httpProxy.createProxyServer({});
//
// Create your custom server and just call `proxy.web()` to proxy
// a web request to the target passed in the options
// also you can use `proxy.ws()` to proxy a websockets request
@ismaels
ismaels / remove_keys_from_redis.sh
Created October 17, 2013 12:24
Remove all keys that follow the indicated pattern from redis using the "redis-cli del" command.
redis-cli keys "TripVo*" | cut -d" " -f 2 | xargs redis-cli del
@ismaels
ismaels / polyline_decoder.js
Created September 20, 2013 12:50
Javascript function to decode google maps api polyline
// source: http://doublespringlabs.blogspot.com.br/2012/11/decoding-polylines-from-google-maps.html
function decode(encoded){
// array that holds the points
var points=[ ]
var index = 0, len = encoded.length;
var lat = 0, lng = 0;
while (index < len) {
var b, shift = 0, result = 0;
@ismaels
ismaels / toggle_element.js
Created March 26, 2013 13:32
Javascript function to toggle an element based on other elements property
//author: Ismael Stahelin
//date: 25.3.2013
//the toggle function
//is based on selected option of a select element. if selected option has the desired property with the desired value
//so another element, in this case a checkbox element is shown, otherwise it is hidden
var toggleTemperature = function(){
var op = $('#tracking_module_tracking_module_model_id option:selected');
if($(op).attr('data-has_temperature_sensor') == 'true'){
$('#temperature_control').show("fast");
}else{
@ismaels
ismaels / fitler-table.coffee
Created March 1, 2013 13:13
Simple method to filter rows in a html table
# filtering row on a table
_searchItems: () =>
criteria = $("#searchItems").val()
$("#schedules_table tbody tr").css('display', 'table-row')
$("#schedules_table tbody tr").not(":contains('#{criteria}')").each () ->
$(this).css('display', 'none')