Skip to content

Instantly share code, notes, and snippets.

View tmm1's full-sized avatar

Aman Gupta Karmani tmm1

View GitHub Profile

FriendlyId uses Rails's extending method to avoid overwriting your model's find method. Internally this is implemented similar to this:

def self.friendly
  all.extending(friendly_id_config.finder_methods)
end

This however comes with a performance impact, because extending invokes Ruby's extend, which blows away MRI's method cache. To work around this, FriendlyId lets you include a :finders module which overrides your model's find to increase performance.

@joestump
joestump / San_Francisco.mkd
Created February 1, 2014 02:05
Here are two tours of San Francisco and the surrounding area. Both take about a day. One is entirely within the city and can be done entirely via public transportation. The other requires a car and gets you outside of SF to some of the wonderful sites that comprise the Yay Area.

San Francisco by Foot

  • You can start anywhere in the Castro, Mission (home of the burrito), or downtown. I'd recommend starting at Chow at Market & Church or The Pork Store on 16th at Valencia. If you wanted to go upscale on the weekend, Maverick at 17th and Mission is a fantastic brunch. Another option is to start in Chinatown (just north of Union Squre) for dim sum.
  • From Castro take one of the N, J, etc. trains (every light rail train route in the city intersects at Church and Market) down to the Powell Street station. From the Mission you can take BART a couple of stops up to Powell Street.
  • Once at Powell Street hop on the Powell Street trolley. A quintessential SF experience.
  • Take the trolley up through the city where it will eventually stop at Lombard Street, which is known as the most crooked street in the world. Walk down the hill, take a few pictures and laugh at the tourists trying to drive down the damn thing.
  • Once at the bottom of the hill, turn left. You'll be walking towards the w
@svagionitis
svagionitis / Create_Iframe_Index_M3U8.bash
Last active January 13, 2024 13:42
Segment an mp4 file to HLS streaming files
#!/bin/bash
# Create an Iframe index from HLS segmented streams
# $1: Filename to be created
# $2: Location of segmented ts files
# Check how many arguments
if [ $# != 2 ]; then
echo "Usage: $0 [Input filename] [Location of segmented streams]"
exit 1;
fi
@adelcambre
adelcambre / 00_tokyo.md
Last active August 29, 2015 14:06
Surviving tokyo

Some basics on Tokyo

Your phone should work

Just like in Europe. It's the same normal international data plan for most carriers (I've done it on At&t and Verizon).

Cash is king

And you get cash from 7-11 (yes I'm serious). American cards very very frequently don't work. Especially in any sort of machine, particularly vending machines and the train ticket machines. Many atm's won't take american cards either. But, every single 7-11 (which are everywhere) has an atm which takes american cards. They sometimes say 7-i, or Seven and i holdings. It's all the same thing (7-11 is actually a japanese company, and they are everywhere). Other than 7-11, every Post office should have an ATM that works too, but they are way less common.

@lrytz
lrytz / z-automator.png
Last active February 4, 2023 21:20
Shortcut for Syntax Highlighting in Keynote
#include <android/log.h>
#include <jni.h>
#include <binder/Binder.h>
#include <binder/Parcel.h>
#include <binder/IServiceManager.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
From c259a69c7e75f29d45fd0bbf47899d15e71e2e79 Mon Sep 17 00:00:00 2001
From: Llorx <dallorx@gmail.com>
Date: Sat, 6 Aug 2016 14:34:50 +0200
Subject: [PATCH] Bitrate on-the-fly PoC
---
ffmpeg.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/ffmpeg.c b/ffmpeg.c
@KatelynHaworth
KatelynHaworth / notifyAddrChange.go
Created June 22, 2017 05:03
A simple go program leveraging the Window API to listen for IPv4 network address change events
package main
import (
"log"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
#import <Foundation/Foundation.h>
@interface KKSimpleAirPlay2Player : NSObject
- (id)initWithURL:(NSURL *)inURL;
- (void)play;
- (void)pause;
@property (readonly, getter=isStopped) BOOL stopped;
@end
@sgdan
sgdan / gzip.kts
Last active May 24, 2024 10:10
Kotlin code to compress/uncompress a string with gzip
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.charset.StandardCharsets.UTF_8
import java.util.zip.GZIPInputStream
import java.util.zip.GZIPOutputStream
fun gzip(content: String): ByteArray {
val bos = ByteArrayOutputStream()
GZIPOutputStream(bos).bufferedWriter(UTF_8).use { it.write(content) }
return bos.toByteArray()