Skip to content

Instantly share code, notes, and snippets.

@aymanfarhat
aymanfarhat / Intersection.py
Created Jan 4, 2013
Set Intersection algorithm O(nlogn) time. Code in Python.
View Intersection.py
from itertools import chain
intersection = []
sets = [[0,4,5,2,1],[1,3,6,2,4],[4,1,2,5,7,0]]
merged = list(chain.from_iterable(sets))
merged.sort()
@vikaskore
vikaskore / RecordAudioViewController.swift
Last active Sep 15, 2019
Record and Play audio in iOS Swift
View RecordAudioViewController.swift
//
// RecordAudioViewController.swift
// Samples
//
// Created by VikasK on 11/02/19.
// Copyright © 2019 Vikaskore Software. All rights reserved.
//
import UIKit
import AVFoundation
@hubgit
hubgit / SelectField.tsx
Last active Sep 15, 2019
Use react-select with Formik
View SelectField.tsx
import { FieldProps } from 'formik'
import React from 'react'
import Select, { Option, ReactSelectProps } from 'react-select'
export const SelectField: React.SFC<ReactSelectProps & FieldProps> = ({
options,
field,
form,
}) => (
<Select
@koenbollen
koenbollen / kns.bash
Last active Sep 15, 2019
kns - Quick kubectl namespace switcher
View kns.bash
#!/bin/bash
# kns lets you select a kubernetes namespace in seconds. Autocomplete,
# type-ahead, everything! (tested in bash and zsh)
kns() {
local current
local namespace
local selected
if [[ ! -x "$(which fzf 2>/dev/null)" ]]; then
echo "please install: github.com/junegunn/fzf" >&2
@DTailor
DTailor / backup_restore.sh
Last active Sep 15, 2019
Backup/Restore PostgreSQL Database
View backup_restore.sh
# List all databases
sudo -u postgres psql --list
# Create backup file
sudo -u postgres pg_dump [database_name] > dumpl.sql
# Drop the database
sudo -u prostgres dropdb [database_name]
# Create a new database
@Yagisanatode
Yagisanatode / Tkinter_filedialog.py
Last active Sep 15, 2019
Python 3 - Open file dialog window in tkinter with filedialog
View Tkinter_filedialog.py
#! Python 3.4
"""
Open a file dialog window in tkinter using the filedialog method.
Tkinter has a prebuilt dialog window to access files.
This example is designed to show how you might use a file dialog askopenfilename
and use it in a program.
"""
@PurpleBooth
PurpleBooth / README-Template.md
Last active Sep 15, 2019
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@bradtraversy
bradtraversy / docker_wordpress.md
Last active Sep 15, 2019
Docker Compose FIle For Wordpress, MySQL & phpmyadmin
View docker_wordpress.md

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@sloria
sloria / bobp-python.md
Created Oct 16, 2013
A "Best of the Best Practices" (BOBP) guide to developing in Python.
View bobp-python.md

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
View sys_setprofile_example.py
>>> import sys
>>> sys.setprofile(lambda *a, **k: print(a,k))
(<frame object at 0x10b2d9c18>, 'return', None) {}
(<frame object at 0x10b2e4428>, 'call', None) {}
(<frame object at 0x10b2e4428>, 'c_call', <built-in method values of dict object at 0x10bc7cfc0>) {}
(<frame object at 0x10b2e4428>, 'c_return', <built-in method values of dict object at 0x10bc7cfc0>) {}
(<frame object at 0x10b2e4428>, 'return', None) {}
>>> def add(a, b):
... return add(a+1,b) if a % 2 == 1 else a+b
...
You can’t perform that action at this time.