Skip to content

Instantly share code, notes, and snippets.

View nZac's full-sized avatar

Nick Zaccardi nZac

View GitHub Profile
@nZac
nZac / gosqrt.go
Last active August 29, 2015 13:56
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) (float64, int) {
z := float64(x)
>>> d = ["25","30","35","40","100","10000","1000000000"]
>>> c = [25,30,35,40,100,10000,1000000000]
>>> sorted(d).pop()
'40'
>>> sorted(c).pop()
1000000000
import os
from os import path as osp
import sys
import keyring
paths_to_link = (
'/usr/lib/python2.7/dist-packages/dbus',
'/usr/lib/python2.7/dist-packages/_dbus_bindings.so',
'/usr/lib/python2.7/dist-packages/_dbus_glib_bindings.so',
-- Create a list of dates incremented by month
DECLARE @MinDate DATE = '20120101',
@MaxDate DATE = '20150101';
SELECT TOP (DATEDIFF(MONTH, @MinDate, @MaxDate) + 1)
full_date = DATEADD(MONTH, ROW_NUMBER() OVER(ORDER BY a.object_id) - 1, @MinDate)
FROM sys.all_objects a
CROSS JOIN sys.all_objects b
@nZac
nZac / max_int_in_dict.py
Created November 2, 2013 19:28
Find the largest int in a dictionary
print stats
# {'a': 3, 'c': 1, 'b': 8}
max(stats.iterkeys(), key=lambda key: stats[key])
# 'b'
# This is my personal zsh-theme file it requires oh-my-zsh and the
# wonderful virtualenv-prompt https://github.com/tonyseek/oh-my-zsh-virtualenv-prompt
# plugin
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
CURRENT_TIME_=" %T%{$reset_color%}"
ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="$FG[237]-----$FG[075] ( venv: "
ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="$FG[075] ) $FG[237]-----"

Keybase proof

I hereby claim:

  • I am nZac on github.
  • I am nzac (https://keybase.io/nzac) on keybase.
  • I have a public key whose fingerprint is 7794 2275 099A 5790 621C 880D 8E9A C0F5 5EB1 256B

To claim this, I am signing this object:

-- Compile to app.js
import Html exposing (Html, button, div, text)
import Html.App as App
import Html.Events exposing (onClick)
main =
App.beginnerProgram { model = 0, view = view, update = update }
type Msg = Increment | Decrement
@nZac
nZac / release.sh
Last active December 15, 2016 16:55
Release PyPI Project
#!/bin/bash -e
#
# Author: Nick Zaccardi <nick.zaccardi@level12.io>
#
# This script is designed to help release packages to PyPI faster. It tries its
# best to walk you through all the steps to release a source packages and a
# binary wheel package.
#
# The script does the following
#
@nZac
nZac / app.py
Last active March 20, 2017 21:36
import flask
import socket
import fcntl
import struct
app = flask.Flask(__name__)
# http://stackoverflow.com/questions/24196932/how-can-i-get-the-ip-address-of-eth0-in-python
def get_ip_address(ifname):