Skip to content

Instantly share code, notes, and snippets.

@jonforums
jonforums / download.rb
Created Mar 26, 2012
Ruby HTTP/HTTPS/FTP file downloader
View download.rb
#!/usr/bin/env ruby
# An HTTP/HTTPS/FTP file downloader library/CLI based upon MiniPortile's
# HTTP implementation.
#
# Author: Jon Maken
# License: 3-clause BSD
# Revision: 2012-03-25 23:01:19 -0600
require 'net/http'
require 'net/https' if RUBY_VERSION < '1.9'
@jonforums
jonforums / ubuntu-nginx-cgit
Last active May 31, 2019
ubuntu server, nginx, and cgit via fcgiwrap+spawn-fcgi
View ubuntu-nginx-cgit
# install nginx via your favorite method
...
# ensure primary nginx config file `/etc/nginx/nginx.conf` contains the following within
# the `http` block so that symlinked config from /etc/nginx/sites-available/* are included
include /etc/nginx/sites-enabled/*;
# install deps and build fcgiwrap
sudo aptitude install spawn-fcgi libfcgi-dev
curl -L -o fcgiwrap-1.1.0.tar.gz http://github.com/gnosek/fcgiwrap/archive/1.1.0.tar.gz
@jonforums
jonforums / yahoo_pull.r
Created Jan 9, 2013
Simple R script to pull historical stock data from Yahoo
View yahoo_pull.r
# Revision: 2013-01-09 12:34:09 -0600
getYahooStockUrl <- function(symbol, start, end, type="m") {
# Creates a Yahoo URL for fetching historical stock data
#
# Args:
# symbol - the stock symbol for which to fetch data
# start - the date (CCYY-MM-DD) to start fetching data
# end - the date (CCYY-MM-DD) to finish fetching data
# type - daily/monthly data indicator ("d" or "m")
@jonforums
jonforums / vm.cpp
Created Sep 29, 2011
Experimenting with exporting symbols from a multi-platform C++ executable
View vm.cpp
// Testing symbol visibility from a C++ executable
// file: vm.cpp
// revision: 09/29/2011 1:42:06 PM
//
// build via:
// export demangled symbols (mingw): g++ -DRBX_API_EXPORT -o vm.exe vm.cpp
// force export (mangled & demangled) symbols (*nix): g++ -o vm vm.cpp -Wl,-export-dynamic
// forced (mangled & demangled) symbol export (mingw): g++ -o vm.exe vm.cpp -Wl,-export-all-symbols
// export no symbols (mingw, *nix): g++ -o vm[.exe] vm.cpp
//
@jonforums
jonforums / xp_gmtime_r.c
Created May 15, 2012
portable gmtime_r testing
View xp_gmtime_r.c
#include <stdio.h>
#include <string.h>
#include <time.h>
#if defined(__MINGW64_VERSION_MAJOR)
/* XXX why isn't this in sec_api/time_s.h? */
# if defined(_USE_32BIT_TIME_T)
# define gmtime_s _gmtime32_s
# else
# define gmtime_s _gmtime64_s
@jonforums
jonforums / build_openssl.ps1
Last active Jul 7, 2016
Automate building OpenSSL on Windows with mingw/mingw-w64
View build_openssl.ps1
#requires -version 2.0
# Author: Jon Maken
# License: 3-clause BSD
# Revision: 2013-03-11 01:24:20 -0600
#
# TODO:
# - extract generics into a downloadable utils helper module
# - add try-catch-finally error handling
# - add checkpoint support
@jonforums
jonforums / Rakefile
Created Jan 16, 2014
rake cmd line task name alchemy
View Rakefile
# Safe little monkey patch to Rake...until it isn't ;)
module Rake
class Application
def top_level_tasks=(tasks)
@top_level_tasks = tasks
end
end
end
puts 'Original top level tasks: %s' % Rake.application.top_level_tasks.inspect
@jonforums
jonforums / buildall.ps1
Last active Dec 21, 2015
Build Go from source using PowerShell
View buildall.ps1
# Author: Jon Maken, All Rights Reserved
# License: 3-clause BSD
# Revision: 2014-04-05 17:44:19 -0600
$toolkit = 'C:\Apps\DevTools\msys32\mingw64\bin'
$targets = 'windows:amd64:1', 'windows:386:0',
'linux:amd64:0', 'linux:386:0',
'darwin:amd64:0', 'darwin:386:0'
$orig_path = $env:PATH
@jonforums
jonforums / uru_pathmunge.go
Last active Dec 19, 2015
new uru PATH handling
View uru_pathmunge.go
package main
import (
"errors"
"fmt"
"os"
"runtime"
"strings"
)
@jonforums
jonforums / uru_dirwalkup.go
Last active Dec 17, 2015
toying with uru's .ruby-version searching impl
View uru_dirwalkup.go
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
)
You can’t perform that action at this time.