Skip to content

Instantly share code, notes, and snippets.

@wrunk
wrunk / jinja2_file_less.py
Last active April 14, 2025 10:17
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@incredimike
incredimike / variousCountryListFormats.js
Last active July 24, 2025 12:21
List of Countries in various Javascript data structures: Alphabetical country lists & Country data objects.
// Lists of countries with ISO 3166 codes, presented in various formats.
// Last Updated: July 30, 2020
// If you're using PHP, I suggest checking out:
// https://github.com/thephpleague/iso3166
// or Laravel: https://github.com/squirephp/squire
//
// JS developers can check out:
// https://www.npmjs.com/package/iso3166-2-db
//
# This is a really old post, in the comments (and stackoverflow too) you'll find better solutions.
def find(key, dictionary):
for k, v in dictionary.iteritems():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
@jonschlinkert
jonschlinkert / markdown-cheatsheet.md
Last active July 25, 2025 20:07
A better markdown cheatsheet.
@nathando
nathando / authenticated_api
Created July 9, 2014 10:21
Authenticated API
@frappe.whitelist(allow_guest=True)
@post_only
def login_test():
try:
frappe.local.login_manager.login()
full_name = frappe.response.pop("full_name")
# Return encrypted token
session_token = AESencrypt('password', str(frappe.local.session.get('sid')))
frappe.local.cookie_manager.set_cookie("sid", "")
return {"status": 1, "full_name": full_name, "s_token": session_token }
@bsweger
bsweger / useful_pandas_snippets.md
Last active June 14, 2025 19:01
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@rkuzsma
rkuzsma / docker-bash-completion.md
Last active June 13, 2025 09:59
How to configure Bash Completion on Mac for Docker and Docker-Compose

How to configure Bash Completion on Mac for Docker and Docker-Compose

Copied from the official Docker-for-mac documentation (thanks Brett for the updated doc pointer):

Install shell completion

Docker Desktop for Mac comes with scripts to enable completion for the docker, docker-machine, and docker-compose commands. The completion scripts may be found inside Docker.app, in the Contents/Resources/etc/ directory and can be installed both in Bash and Zsh.

Bash

Bash has built-in support for completion To activate completion for Docker commands, these files need to be copied or symlinked to your bash_completion.d/ directory. For example, if you installed bash via Homebrew:

@kevinadi
kevinadi / mongodb-ssl.sh
Last active March 24, 2025 10:32
Script to create self-signed CA certificates, server certificates, and client certificates for testing MongoDB with SSL
#!/bin/sh
# Generate self signed root CA cert
openssl req -nodes -x509 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "/C=AU/ST=NSW/L=Sydney/O=MongoDB/OU=root/CN=`hostname -f`/[email protected]"
# Generate server cert to be signed
openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj "/C=AU/ST=NSW/L=Sydney/O=MongoDB/OU=server/CN=`hostname -f`/[email protected]"
# Sign the server cert
@dnaismyth
dnaismyth / ViewController.swift
Created October 22, 2017 17:33
DZNEmptyDataSet Example
import UIKit
import DZNEmptyDataSet
class ViewController: UIViewController, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
@IBOutlet var tableView: UITableView!
let tungsten: UIColor = UIColor(red:0.20, green:0.20, blue:0.20, alpha:1.0)
override func viewDidLoad() {