Skip to content

Instantly share code, notes, and snippets.

View endel's full-sized avatar

Endel Dreyer endel

View GitHub Profile
@jaredallard
jaredallard / string.split.lua
Created May 21, 2015 05:07
string.split in lua
-- split a string
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
@lucas-tulio
lucas-tulio / cpf-generator.sql
Last active September 5, 2021 16:09
Gerador de CPF em MySQL
select concat(substr(cpf, 1, 3), '.', substr(cpf, 4, 3), '.', substr(cpf, 7, 3), '-', first_dig, if(second_soma % 11 < 2, 0, 11 - (second_soma % 11))) AS cpf
from (
select cpf, first_dig, second_one+second_two+second_three+second_four+second_five+second_six+second_seven+second_eight+second_nine+second_ten AS second_soma
from (
select
cpf,
11*original_one AS second_one,
10*original_two AS second_two,
9*original_three AS second_three,
8*original_four AS second_four,
@dhoelzgen
dhoelzgen / base_controller.rb
Last active October 7, 2021 16:19
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@momo-the-monster
momo-the-monster / threejsatlasloader.js
Last active May 5, 2022 14:51
Three.JS Atlas Loader
// json is a JSON atlas generated by TexturePacker
// imagepath is a url to the full texture atlas image
var atlasTexture = THREE.ImageUtils.loadTexture( imagepath, undefined, function() {
for (var key in json.frames) {
var tex = atlasTexture.clone();
var frame = json.frames[key].frame;
tex.repeat.x = ( frame.w / atlasTexture.image.width );
@PaulKinlan
PaulKinlan / criticalcss.html
Last active March 15, 2023 02:13
Detect Critical CSS
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<h2>Original CSS</h2>
<style style="display: block; white-space: pre; font-family: monospace">
h2 { margin:0; }
@ryandotsmith
ryandotsmith / hack-reactor.md
Last active November 24, 2022 07:01
Hack Reactor Talk

Tales From a Heroku User

Here are some things I have learned along the way.

Last Updated: 2013-02-08

Original Audience: Hack Reactor

About

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@endel
endel / gist:3623976
Created September 4, 2012 17:40 — forked from emerleite/gist:3621544
Velocity 2012 - Anotações
http://estelle.github.com/mobileperf/#slide55
https://github.com/impressiver/velocity2012
https://github.com/jonlives/velocity_resources
Chef - Jon Cowie (Etsy)
Ele tem um handler que consegue mandar o que falha para or irc usando
@tobyhede
tobyhede / postsql.sql
Created May 17, 2012 03:08
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};