Skip to content

Instantly share code, notes, and snippets.

View nhocki's full-sized avatar
💭
I may be slow to respond.

Nicolás Hock-Isaza nhocki

💭
I may be slow to respond.
View GitHub Profile
@ChristopherA
ChristopherA / macOS-Preferences-Defaults.sh
Last active April 17, 2024 11:06
macOS Preferences Defaults
#!/usr/bin/env zsh
#===========================================================================
# * INFO
#
# macOS Preferences Defaults
# By Christopher Allen @ChristopherA https://github.com/christophera/
# My most basic macOS preferences, in this gist to make it easy to load on
# multiple machines and VMs. Ideally runs on all macOS versions since Yosemite,

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Command caption reads an audio file and outputs the transcript for it.
package main
import (
"fmt"
"io"
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@skwp
skwp / dynamic_method_spec.rb
Created December 7, 2013 00:44
Fail your build for user-defined style rules.
require 'spec/support/grep_matcher'
describe do
disallow_presence_of pattern: "send(.*#",
location: "app/",
description: "Do not use dynamic method invocations",
failure: "Please change dynamic method call to something more sane."
end
@hgmnz
hgmnz / dblink-demo
Created March 6, 2013 16:33
How to move data from one postgres database to another using dblink. Useful for cherry-picking data from a remote database
@nhocki
nhocki / flip_region.cc
Last active December 13, 2015 23:29
Small programming challenges
// Given a boolean matrix, and a point (x, y) you need to
// change the values for all the adjacent (x1, y1) such that |x-x1| + |y-y1| = 1
// (neighbors with adjacent side)
#define flip!(x, y) matrix[x][y] = !matrix[x][y]
int xs = {-1, 0, 1, 0};
int ys = {0, 1, 0, -1};
bool visited[D+1][D+1];
String.prototype.midTruncate = function(length, seperator){
var left, right;
length = length || 30, left = Math.ceil(length/2), right = Math.floor(length/2);
seperator = seperator || '…';
if (this.length<=(length+1)) return this.toString();
return this.slice(0,left).strip()+seperator+this.slice(-right,this.length).strip();
};
-T
-d postgresql
def change_log(stream)
# send Rails logs to console
# 2.X
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
Object.const_set 'RAILS_DEFAULT_LOGGER', Logger.new(stream)
end
@jeremy
jeremy / gist:4211803
Created December 5, 2012 03:05
Template- and asset-aware ETags

Declared ETags, together with Russian Doll caching, can be used to automatically mix your template and asset versions into the ETags set in your controllers. This avoids the need to blow all browser caches on each deploy and neatly contains the scope of "freshness fallout" when you tweak a view.

To include the template's version in the ETag:

  # Incorporate the cache version for this action into our ETag.
  # This allows template changes to bubble up into HTTP cache
  # freshness and bust browser caches when we make changes.
  etag do
    begin