Skip to content

Instantly share code, notes, and snippets.

View blakek's full-sized avatar
☦️

Blake Knight blakek

☦️
View GitHub Profile
@blakek
blakek / c_vector.c
Last active December 26, 2015 14:09 — forked from sshtmc/simple_c_vector.h
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "c_vector.h"
// Return the vector size
size_t vector_size(vector *v)
{
return v->size;
}
@blakek
blakek / make_iphone_libs.sh
Created November 21, 2013 16:05
Meant to help me make open source libraries with for iPhone. Only works with systems that use the "./configure && make && make install" approach.
#!/bin/sh
# Runs `./configure && make && make install' with variables set to help build libraries for iOS devices more easily.
# Hopefully, this will work as-is, but some notes...
# TODO: At least attempt to find correct directories without just failing with weird error messages
# > $DEVROOT _will_ have to change according to Xcode installation directory.
# > $CC or $CXX will probably change whenever a new compiler version is installed
# > $IOS_BASE_SDK or $IOS_DEPLOY_TGT may be changed to fit developer's needs as well as future Xcode layout changes (e.g. dropping support for older iOS versions)
# > Currently, a library for the simulator isn't being made (but should be _really_ easy to add with the existing script)
IOS_BASE_SDK="5.0"
@blakek
blakek / install-yaourt.sh
Last active October 29, 2019 06:32
An easy yaourt install script for Arch Linux (and variants). Made so I can set up Arch either offline or online without having to remember what I need.
#!/bin/bash -e
make_a_pkg() {
printf '** Making package "%s"...\n' "$1"
tar zxf "$1.tar.gz"
cd "$1"
makepkg -si
cd ..
}
@blakek
blakek / rename.py
Created March 16, 2015 14:06
Rename files using regular expressions
#! /usr/bin/env python
import argparse, os, re
beVerbose = False
def rename_files(replaceStr, withStr, files):
for file in args.files:
newName = re.subn(replaceStr, withStr, file)
if newName[1] != 0:
if beVerbose: print(file + ' => ' + newName[0])
@blakek
blakek / update-git-repos.sh
Created March 16, 2015 14:09
Updates (via git pull) all github repos in the current directory
#!/bin/bash
for f in *; do
if [ -d "$f/.git" ]; then
pushd "$f" && git pull --quiet && popd
fi
done
@blakek
blakek / r-install.sh
Last active August 29, 2015 14:17
Installs R and rattle for OS X users (with automatic GTK 2 install using Homebrew)
#!/bin/bash
# This is boring... the least we can do is have nice colors!
white='\e[1;37m'
black='\e[0;30m'
blue='\e[0;34m'
light_blue='\e[1;34m'
green='\e[0;32m'
light_green='\e[1;32m'
cyan='\e[0;36m'
#!/usr/bin/env ruby
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
output=''
#!/bin/bash
# If today is between two dates (following the YYYY-MM-DD format), then return "success" (e.g. 0).
# Else, return error (1).
time_between() {
begin_date=$1
end_date=$2
today=`date '+%Y-%m-%d'`
# Bash (usually) has no '>=' or '<=' when it comes to string comparison, so
@blakek
blakek / geoloc.js
Created August 13, 2015 15:26
weather stuff
'use strict';
function GeoLoc (lat, lon) {
this.lat = lat;
this.lon = lon;
}
function toRad(dec) {
return Math.PI * dec / 180;
}
@blakek
blakek / index.js
Created August 14, 2015 17:49
Install packages using npm
var npm = require('npm');
function npm_ready (err) {
if (err) {
console.log(err);
}
console.log('Searching...');
npm.commands.search(['wa-source-'], false, function (err, data) {
console.log('Search done.');