Skip to content

Instantly share code, notes, and snippets.

@ohld
ohld / code_to_media_id.py
Created February 19, 2020 20:14
Convert Instagram media URL to media_id
# This is Python port of this Javascript method:
# https://github.com/notslang/instagram-id-to-url-segment/blob/master/lib/index.coffee
url = "https://www.instagram.com/p/B8iwlG9pXHI/"
# ----> use regexp to extract code from url
code = "B8iwlG9pXHI"
charmap = {
'A': '0',
'B': '1',
@SeppPenner
SeppPenner / Installing Python 3.7.4 on Raspbian.rst
Last active January 8, 2024 12:33
Installing Python 3.7.4 on Raspbian

Installing Python 3.7.4 on Raspbian =================================

As of July 2018, Raspbian does not yet include the latest Python release, Python 3.7.4. This means we will have to build it ourselves, and here is how to do it.

  1. Install the required build-tools (some might already be installed on your system).

@jmindek
jmindek / gist:62c50dd766556b7b16d6
Last active January 31, 2024 15:48
DISTINCT ON like functionality for Redshift

distinct column -> For each row returned, return only the unique members of a set. Think of it as for each row in a projection, concatenate all the column values and return only the strings that are unique.

test_db=# SELECT DISTINCT parent_id, child_id, id FROM test.foo_table ORDER BY parent_id, child_id, id LIMIT 10;
parent_id | child_id | id
-----------+------------+-----------------------------
1000040 | 103 | 1000040|2645405726|0001|103
@mchambers
mchambers / reflect.swift
Last active March 5, 2021 09:20
Basic Reflection in Swift.
// Let's define a basic Swift class.
class Fruit {
var type=1
var name="Apple"
var delicious=true
}
// We can get at some info about an instance of an object using reflect(), which returns a Mirror.
reflect(Fruit()).count
reflect(Fruit())[1].0
@rtt
rtt / tinder-api-documentation.md
Last active April 20, 2024 17:01
Tinder API Documentation

Tinder API documentation

Note: this was written in April/May 2014 and the API may has definitely changed since. I have nothing to do with Tinder, nor its API, and I do not offer any support for anything you may build on top of this. Proceed with caution

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@hmans
hmans / application.html.slim
Last active October 27, 2023 17:52
Application layout for Rails (4 and 5), Slim style.
doctype html
html
head
title My App
meta name="viewport" content="width=device-width, initial-scale=1.0"
= stylesheet_link_tag "application", media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag "application", 'data-turbolinks-track' => true
= csrf_meta_tags
body
@rjregenold
rjregenold / ActiveRecord2iOS_Timezones.plist
Created March 26, 2013 04:33
Map ActiveRecord timezone names to NSTimeZone names.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Information</key>
<dict>
<key>Description</key>
<string>Map Rails ActiveSupport timezones to iOS readable timezone IDs.</string>
<key>Version</key>
<string>1.0</string>
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………