Skip to content

Instantly share code, notes, and snippets.

View davidcelis's full-sized avatar
Verified account

David Celis davidcelis

Verified account
View GitHub Profile
@beginor
beginor / snowflake-id.sql
Last active April 18, 2024 20:13
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@arthurnn
arthurnn / example_test.rb
Last active October 29, 2018 04:57
Load ActiveRecord fixtures from a block instead of a yml file
require 'minitest/autorun'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDOUT)
conn = { adapter: 'sqlite3', database: ':memory:' }
ActiveRecord::Base.establish_connection(conn)
class User < ActiveRecord::Base
connection.create_table :users, force: true do |t|
t.string :username
@aredridel
aredridel / boot-coreos.sh
Last active January 4, 2016 18:12
Set up and boot CoreOS on top of a stock DigitalOcean Fedora 19 install. Abuses the Fedora 19 root as the CoreOS STATE partition. Still todo: copy SSH keys from Fedora install.
#!/bin/sh
kexec --load /boot/coreos_production_pxe.vmlinuz --initrd=/boot/coreos_production_pxe_image.cpio.gz --append='state=/dev/vda root=squashfs: sshkey="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQCZ3fvhC7StXFdFRuXApBuXyS2phoH7ZVKMUMOi3DrbnZWC01GUq74WdalRDHtfq2dl0CPctLb8RHSD+/dKgWEH0gmoEOCio09ZAY5Ui4Cy+0cCGefXkUnJR4lgNOYD076BXjJwsCVCD8sMlFFT08Qn4/voP0jpL1uvvoWiC1KSvSjZf7sP/hRgsO633OuclXyVVq7mC6q+2QVg6hfO49Gt7TVXb+8lc8aUHAYyrXEVag6oICWqxWlSglbEpXCXhK4RB1f8h2vCaEPe2Kf1LNPYJ3dN5H5v+tnst9oZbFjo/qNSm4RvPBb3nsNARdcemdGcwiTjAiIn9gMxBMOyiYOYSgVwGd2U76FR0/RUFUORprynn6uebBhtpGzIAuFsUygMAPAM2tocO+t+h8AQviF6IeA9rKwf5bFTXV9HLy+iUoCWsVBmGypfGbsD7UNg3DIpXv4FdoLDDiCq+OV16ludjLk5pjknshH0cII+Q5b1fcITKSMrZ0CnMytkHHYPTvJ/uc2W9p3howAbMCs+WpNsSnLoCfq5ZjWclauV9Sn7OULQSMuKzTBF+bN7FOyolPbFrW+B3ESUpbonbLbKOubvsBjnUQLNoNjH4pa5Sg3Pluh1EoYLq/oKYU/C+SSwnbRy9N1h2z5UZy/CyrGNG8UomkuFIZWOAGH+zqwU1iCYaWHPgUNXM+4gSe0cGmVesFRpco5nhqvHGdDtw3OCC1U0f9jj6Pk+4jFmulj45+Hu4ZEL8wyMlftbycT8KtuqSVOD/yuytPFlvBzFrjP9s3V8ZN46y5rLpR9dAD+DJHYVESGxQV9lLq2g0p8IJ
@chengyin
chengyin / linkedout.js
Last active July 11, 2021 15:23
Unsubscribe all LinkedIn email in "one click". For an easier to use version, you can check out the bookmarklet: http://chengyin.github.io/linkedin-unsubscribed/
// 1. Go to page https://www.linkedin.com/settings/email-frequency
// 2. You may need to login
// 3. Open JS console
// ([How to?](http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers))
// 4. Copy the following code in and execute
// 5. No more emails
//
// Bookmarklet version:
// http://chengyin.github.io/linkedin-unsubscribed/
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
#!/usr/bin/env ruby
#
# This script can be used to check the in-store availability of the iPhone 5S.
# By default, it searches for all AT&T models. You can change this by editing
# the MY_DEVICES array below. While the Apple API supports searching for
# multiple devices at once, there is a limit.
#
# Once you have properly configured the MY_DEVICES array, you can run this script
# from the terminal. It takes a single parameter, which should be the zip code you
# wish to use for your search.
module CheapStrings
def `(str)
str
end
end
module A
extend CheapStrings
def self.make_lots_of_strings
begin;
create table user_ratings (
id serial primary key,
user_id integer not null,
rating integer not null check (rating >= 0 and rating <= 5),
ratable_id integer not null
);
create function random_int(max integer) returns integer as $$
@davidcelis
davidcelis / 2013_Ruby_on_Ales_notes.md
Last active December 14, 2015 15:39
Ruby on Ales 2013 — Conference Notes

Table of Contents

[The End of Fun][end-of-fun] ([@sarahmei][@sarahmei])

[Hacking Cognition][hacking-cognition] ([@1773807][@1337807])

[Services and Rails][services-and-rails] ([@brianxq3][@brianxq3])

[How Ruby Makes Better Beer][better-beer] ([@cadwallion][@cadwallion])

@postmodern
postmodern / gemcutter_rce.rb
Created January 30, 2013 18:35
Proof-of-Concept (PoC) exploit for Gemcutter utilizing the YAML deserialization vulnerability.
#!/usr/bin/env ruby
#
# Proof-of-Concept RCE exploit against Gemcutter
#
# ## Advisory
#
# * TBA
#
# ## Caveats
#