Skip to content

Instantly share code, notes, and snippets.

View gamikun's full-sized avatar
🐷

Gamaliel Espinoza M. gamikun

🐷
View GitHub Profile
@gamikun
gamikun / BusquedaTildes.php
Created December 5, 2014 21:21
Buscar con tildes en PostgreSQL sin importar si es mayúscula o minúscula.
<?php
class BusquedaTildes {
private static $___tildes_origen = array(
'a', 'e', 'i', 'o', 'u',
'á', 'é', 'í', 'ó', 'ú',
'ñ', 'ü'
);
private static $__tildes_codificado = array(
'á', 'é', 'í', 'ó', 'úü',
@gamikun
gamikun / MinecraftNBTParser.py
Last active August 29, 2015 14:10
Simple Minecraft NBT parser for Python
class NBTParser(object):
END = 0
BYTE = 1
COMPOUND = 10
SHORT = 2
INT = 3
LONG = 4
FLOAT = 5
DOUBLE = 6
BYTE_ARRAY = 7
@gamikun
gamikun / curl.php
Last active June 29, 2016 18:23
Very simple HTTP Request with PHP cURL
<?php
$url = curl_init("http://teamlod.es/imga/imgur.php");
curl_setopt($url, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec($url)
@gamikun
gamikun / RandomWebserviceMD5.py
Last active August 29, 2015 14:15
Random MD5 service in Python
from binascii import hexlify
from os import urandom
from wsgiref.simple_server import make_server
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [hexlify(urandom(16))]
make_server('', 8000, app).serve_forever()
from __future__ import print_function
import sys
import math
import time
db = []
with open("./lonlat", 'rb') as fi:
for l in fi:
<!DOCTYPE html>
<html>
<head>
<title>Mi fondo se mueve!</title>
<script type="text/javascript">
window.onload = function() {
document.onmousemove = function(e) {
var x = -(e.clientX/10);
var y = -(e.clientY/10);
this.body.style.backgroundPosition = x + 'px ' + y + 'px';
while (true) {
console.log("je");
}
# CodeFights perfectCity
def perfectCity(departure, destination):
import math
sx, sy = departure
tx, ty = destination
distances = []
for i in [math.floor, math.ceil]:
x = sx
@gamikun
gamikun / fareEstimator.py
Created June 29, 2016 18:20
CodeFights.UberBot.fareEstimator
def fareEstimator(ride_time, ride_distance, cost_per_minute, cost_per_mile):
estimations = []
for i, rtime in enumerate(ride_time):
rdist = ride_distance[i]
permin = cost_per_minute[i]
permile = cost_per_mile[i]
est = (rtime * permin) + (permile * rdist)
estimations.append(est)
return estimations
@gamikun
gamikun / bitpack.php
Created February 25, 2017 21:20
Boolean bitpacking for PHP
<?php
/**
* Given an array of numbers (of 24 bits/hours),
* where each bit of the number is equal to 1 hour,
* validates if the corresponding hour and day is on.
*
* @param $days Array of ~24 bits numbers.
* @param $day Number from 0 to 7
* @param $hour 0 to 23