Skip to content

Instantly share code, notes, and snippets.

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

codecakes codecakes

💭
I may be slow to respond.
View GitHub Profile
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@codecakes
codecakes / upgrade.md
Created March 21, 2017 07:28 — forked from chrismccord/upgrade.md
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@codecakes
codecakes / replace.sh
Created May 10, 2017 16:33
replace older package version name to newer one
#!/bin/bash
OLD="xenial"
NEW="zesty"
DPATH="/etc/apt/sources.list*"
BPATH="./play/"
TFILE="./play/out.tmp"
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
do
if [ -f $f -a -r $f ]; then
@codecakes
codecakes / install-postgres-10-ubuntu.md
Created January 15, 2018 09:24 — forked from alistairewj/install-postgres-10-ubuntu.md
Install PostgreSQL 10 on Ubuntu

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple.

dpkg -l | grep postgres
@codecakes
codecakes / backup_restore.sh
Created January 17, 2018 07:22
restores backed up repo and keys from older ubuntu packages and adds new versions packages
OLD="saucy\|precise\|zesty\|trusty\|raring\|xenial"
NEW="bionic"
OLD_SOURCES="./sources.list*"
find $OLD_SOURCES -type f -print0 | xargs -0 sed -i "s/$OLD/$NEW/gi"
sudo cp -R ./sources.list* /etc/apt/
sudo apt-get update
sudo apt-get install dselect
sudo dselect update
sudo apt-cache dumpavail > ~/temp_avail
@codecakes
codecakes / gist:7b949b1f323e8792d5a382da023a1463
Created April 25, 2018 20:40 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@codecakes
codecakes / shuffle.ts
Last active July 2, 2018 10:13
typescript shuffling an array using new constructor classes
interface ContactInf {
name: string;
numbers: (number|string)[];
}
class Contact implements ContactInf {
constructor (public name: string, public numbers: (number|string)[]) {
console.info('creating');
};
// new es6 style
@codecakes
codecakes / slices_render_image_.go
Created August 22, 2018 11:09
a golang exercise to render a blue pixel image of dimensions dx, dy
package main
import "golang.org/x/tour/pic"
type funcIntType func(int)
func DivideFn(lo, hi int, fn funcIntType) {
if mid := int((hi - lo)/2 + lo); lo < hi {
DivideFn(lo, mid, fn)
DivideFn(mid+1, hi, fn)
@codecakes
codecakes / word_count.go
Created August 22, 2018 13:05
count words in go
package main
import (
"strings"
"golang.org/x/tour/wc"
)
func WordCount(s string) map[string]int {
result := make(map[string]int)
present := false
@codecakes
codecakes / fibonacci.go
Created August 22, 2018 13:35
// fibonacci is a function that returns // a function that returns an int.
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a, b, c := 0, 1, 0
return func() int {
c = a