Skip to content

Instantly share code, notes, and snippets.

View dgilperez's full-sized avatar
🌊
Build that!

David Gil dgilperez

🌊
Build that!
View GitHub Profile
@nkbt
nkbt / .eslintrc.js
Last active April 23, 2024 03:19
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@zanona
zanona / sentry-serverless-firebase.ts
Last active April 3, 2024 15:48
Missing Sentry's firebase serverless wrappers
/**
* Temporary wrapper for firebase functions until @sentry/serverless support is implemented
* It currently supports wrapping https, pubsub and firestore handlers.
* usage: https.onRequest(wrap((req, res) => {...}))
*/
import type {Event} from '@sentry/types';
import type {https} from 'firebase-functions';
import type {onRequest, onCall} from 'firebase-functions/lib/providers/https';
import type {ScheduleBuilder} from 'firebase-functions/lib/providers/pubsub';
import type {DocumentBuilder} from 'firebase-functions/lib/providers/firestore';
@funny-falcon
funny-falcon / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@bkimble
bkimble / gist:1365005
Last active March 22, 2024 19:21
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@tjh
tjh / character_set_and_collation.rb
Created January 31, 2012 16:07
Convert all Rails table column collation and character set
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
#
# > ruby character_set_and_collation.rb
DATABASE = ''
@runemadsen
runemadsen / description.markdown
Created September 26, 2011 15:23
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@iamatypeofwalrus
iamatypeofwalrus / add_milliseconds_to_mysql_and_activerecord_timestamps.md
Last active February 2, 2024 15:38
ActiveRecord: Store Milliseconds (or Microseconds) in Timestamps/Datetimes with Rails / MySQL

ActiveRecord: Store Milliseconds (or Microseconds) in Timestamps with Rails / MySQL

Milliseconds in your Timestamps.

We got 'em, you want 'em.

Why

Shit needs to be PRECISE

LICENSE

MIT

@aortbals
aortbals / squash-and-merge-cli.md
Last active January 16, 2024 10:46
Squash and Merge on the Command line

With the introduction of GitHub's Squash and Merge feature, this has become less prevelant, however it's still useful in scenarios where GitHub's interface is unavailable.

Let's talk through two ways to do a squash and merge on the command line.

Take 1: Interactive Rebase

When to use it

  • When you have not merged main into your feature branch
  • There are no merge conflicts
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@jdiaz5513
jdiaz5513 / ascii_arty.py
Last active December 30, 2023 02:32
Console ASCII Art Generator
#! /usr/bin/env python2
# Requires: PIL, colormath
#
# Improved algorithm now automatically crops the image and uses much
# better color matching
from PIL import Image, ImageChops
from colormath.color_conversions import convert_color
from colormath.color_objects import LabColor
from colormath.color_objects import sRGBColor as RGBColor