Skip to content

Instantly share code, notes, and snippets.

Avatar

Noah Bass noahbass

View GitHub Profile
@noahbass
noahbass / nodejs-tcp-example.js
Created Sep 18, 2018 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
View nodejs-tcp-example.js
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
View kata.swift
import XCTest
typealias Quality = Int
typealias SellIn = Int
typealias UpdateRule = (Quality, SellIn) -> Quality
enum ItemType {
case normal
View acmatuc-attendance.py
# First, run:
# virtualenv venv
# . venv/bin/activate
# pip install beautifultable
import csv
from beautifultable import BeautifulTable
# import numpy as np
# map: 6+2 -> graduation_date
@noahbass
noahbass / index.html
Last active Jul 26, 2016
Meteor external api example: bibles.org api
View index.html
<head>
<title>meteor external api example</title>
</head>
<body>
<table>
<p>{{{verse.verse}}}</p>
<p>{{{verse.text}}}</p>
</table>
</body>
View .bash_prompt
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
View Simple prime gen.php
<?php
function main()
{
$count = 3;
$count2 = 1;
while(True) {
$isprime = True;
View .bash_prompt
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
@noahbass
noahbass / binary2num.py
Created Nov 11, 2014
convert a binary to an integer
View binary2num.py
b = '10' # binary input
b = b[::-1]
number = 0
for i in b:
i = int(i)
if i != 0:
number += 2**i
@noahbass
noahbass / num2binary.py
Created Nov 11, 2014
convert an integer to a binary
View num2binary.py
i = 10
nums = []
if i == 0:
nums.append(0)
else:
while i >= 1:
if (i//2) % 2 == 0:
nums.append(1)
View jekyll.lunr.js
var index = lunr(function() {
this.field('title', {
boost: 10
})
this.field('body')
this.ref('id')
});
{% for post in site.posts %}
index.add({
You can’t perform that action at this time.