Skip to content

Instantly share code, notes, and snippets.

View rosenfeld's full-sized avatar

Rodrigo Rosenfeld Rosas rosenfeld

View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active November 12, 2024 19:08
Listen to your web pages
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active October 24, 2024 18:10
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@Restuta
Restuta / framework-sizes.md
Last active September 19, 2024 15:32
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@danielgtaylor
danielgtaylor / gist:0b60c2ed1f069f118562
Last active April 2, 2024 20:18
Moving to ES6 from CoffeeScript

Moving to ES6 from CoffeeScript

I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.

In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.

While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.

Punctuation

Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio

@andywenk
andywenk / email_address_validator.rb
Created September 3, 2014 10:34
simple email adress validator; checks if the server responds and has an MX or A record
require 'mail'
require 'resolv'
require 'net/telnet'
class EmailAddressValidator < ActiveModel::EachValidator
attr_reader :mail
def validate_each(record, attribute, value)
return if options[:allow_nil] && value.nil?
@headius
headius / test.rb
Last active January 2, 2016 10:09 — forked from rosenfeld/output.txt
Example utility for doing synchronized updates of instance variables.
module Atomically
GLOBAL_MUTEX = Mutex.new
def atomically(varname, &block)
# check first to avoid locking if possible
instance_variable_get(varname) || ___atomically_update___(varname, &block)
end
def ___atomically_update___(varname)
# lock and do ||= update
___mutex___.synchronize do
@rosenfeld
rosenfeld / bookmarks
Last active December 20, 2015 06:09
bookmarks
http://rubysource.com/streaming-with-rails-4/
http://www.highcharts.com/
https://bitbucket.org/cleonello/jqplot/wiki/Home
http://www.dreamfactory.com/
http://coding.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css/
http://tech.pro/blog/1486/client-side-storage-options
https://www.globalsign.com/ssl/ssl-open-source/
http://nowardev.wordpress.com/2012/05/16/create-debian-package-for-script-and-simple-project-with-cmake-and-cpack/
http://shvets.github.io/blog/2013/09/14/nodejs_and_karma.html
@adamsanderson
adamsanderson / Gemfile
Last active January 23, 2024 14:08
Demonstration of hierarchical queries in Postgres using a materialized path. It will create a new database that you can later play around with.
source 'https://rubygems.org'
gem 'activerecord', '4.0.0.rc1'
#!/usr/bin/tclsh8.5
#
# Usage: git-unmerged branch1 branch2
#
# Shows all the non-common commits in the two branches, where non-common
# commits means simply commits with a unique commit *message*.
proc getlog branch {
lrange [split [exec git log $branch --oneline] "\n"] 0 400
}
@coldnebo
coldnebo / rails_trace.rb
Last active August 15, 2024 15:15
This Rack middleware for Rails3 lets you see a call-trace of the lines of ruby code in your application invoked during a single request. Only code within your app is considered (i.e. in the /app folder). This expands on my previous attempt (https://gist.github.com/3077744). Example of output in comments below.
require 'singleton'
# outputs a colored call-trace graph to the Rails logger of the lines of ruby code
# invoked during a single request.
#
# Example:
#
# 1) Make sure this file is loaded in an initializer
#
# 2) Add the following to your application.rb in Rails3: