Skip to content

Instantly share code, notes, and snippets.

View dannguyen's full-sized avatar
💭
havin a normal one

Dan Nguyen dannguyen

💭
havin a normal one
View GitHub Profile
@pztrick
pztrick / fancyimage_tag.rb
Created June 21, 2012 01:33
Jekyll Image plugin that dynamically creates thumbnails and fancyboxes for uploaded images
# Title: Fancyimage tag for Jekyll
# Authors: Devin Weaver (photos_tag.rb), Brian M. Clapper (img_popup.rb), Patrick Paul (this gist)
# Description: Takes full size image, automagically creates thumbnail at specified size, +fancybox
#
# Adapted from:
# http://tritarget.org/blog/2012/05/07/integrating-photos-into-octopress-using-fancybox-and-plugin/
# (photos_tag.rb) https://gist.github.com/2631877
# (img_popup.rb) https://github.com/bmc/octopress-plugins/
#
# Syntax {% photo filename [tumbnail] [title] %}
@andy-esch
andy-esch / stanford-workshop.md
Last active October 9, 2015 22:28
Stanford CartoDB Workshop 3/9/2015
@totty90
totty90 / jquery-backbone version
Created January 1, 2014 16:32
React example vs jquery in pure javascript
var BuildTemplate = ' \
<h2 class="small-caps">build</h2> \
';
var BuildV = BaseV.extend({
className: 'btn-group-vertical',
initialize: function(o){
this.__player = o.player;
@vaguity
vaguity / Hacks-Hackers NYC: Encryption and Operational Security for Journalists (2013-09-16).md
Last active April 29, 2016 17:34
Notes from Hacks/Hackers NYC workshop on encryption and opsec for journalists. Notes come from talk by Jennifer Valentino.

Hacks/Hackers NYC: Encryption and Operational Security for Journalists (2013-09-16)

Jennifer Valentino, Wall Street Journal (@jenvalentino)

These notes come straight from Jennifer's presentation; slides at https://docs.google.com/file/d/0B2HGtAJEbG8PdzVPdHcwekI2V2M/edit

Background

  • NSA covers 75% of internet traffic; not all is collected or sifted
  • Big issues with suveillance are not the NSA but leak investigations, subpoenas, accidental disclosure and chilling effects on sources
@toddwschneider
toddwschneider / nyc_taxi_uniquely_identifiable.md
Created December 1, 2015 12:28
How many NYC taxi trips are uniquely identifiable by census tracts and the hour of pickup time

40% of NYC Taxi Trips are Uniquely Identified by Pickup/Drop Off Census Tracts and Hour

In my recent post analyzing 1.1 billion NYC taxi and Uber trips, I included a section about privacy concerns which showed how precise latitude/longitude coordinates of taxi pickups and drop offs could potentially be used to reveal personal information about where people live, work, socialize, etc.

I wrote that if the Taxi & Limousine Commission wanted to avoid disclosing personal information, they would have to remove latitude/longitude from the dataset, perhaps replacing them with coarser census tract location data. Now it seems like maybe census tracts are still too precise.

I hadn't previously investigated how well census tracts uniquely identify pickups and drop offs, but **it turns out that if you

@xaviershay
xaviershay / github_requests.md
Last active April 11, 2018 03:20
Pull request feature requests

Hello Github,

Pull requests are not serving me well on large reviews. Here are some problems and suggested enhancements that would make me happy.

  • Mark comment as "resolved" (see google docs for an example). As code changes, comments get lost or made redundant, and it is not clear (to either the author or reviewers) which are still relevant and which have been addressed. Resolving a comment doesn't need to make it dissappear, but I need to be able to see "which comments have not been addressed" somehow. This feature would be the most useful to me.
  • Reply to a comment. This can be done in effect on line comments (assuming there is only one), but cannot on PR comments. Particularly with many threads, the lack of this makes a review hard to follow.
  • Explicit "approve/block" life cycle. The block is actually more important to me ... often on a PR that has been incrementally improved I want to "block" final merge of it until I get a chance to rebase/squash and generally pretty it up. The block can be over
@simonw
simonw / deepest.sql
Created October 6, 2019 17:15
Query a twitter-to-sqlite database and find the "deepest" tweets in a reply thread, adapted from https://gist.github.com/robinhouston/f689a4b833dc027a3fd97e3de855927b
with recursive thread as (
select id, in_reply_to_status_id, 0 as depth
from tweets
where in_reply_to_status_id is null
union
select tweets.id, tweets.in_reply_to_status_id, 1 + thread.depth as depth
from thread join tweets on tweets.in_reply_to_status_id = thread.id)
select * from thread order by depth desc
@benedikt
benedikt / rails.rb
Created July 30, 2011 13:16
Capistrano task to open a rails console on a remote server. Require this file in your deploy.rb and run "cap rails:console"
# encoding: UTF-8
Capistrano::Configuration.instance(:must_exist).load do
namespace :rails do
desc "Open the rails console on one of the remote servers"
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
end
end
@willurd
willurd / Getting started with requirejs.md
Last active December 14, 2022 08:15
A short introduction to require.js

This is a small collection of scripts showing how to use require.js. It's only one of several ways of setting up a require.js project, but it's enough to get started.

At its core, require.js is about three things:

  1. Dependency management
  2. Modularity
  3. Dynamic script loading

The following files show how these are achieved.

# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do