Skip to content

Instantly share code, notes, and snippets.

@evanwalsh
evanwalsh / import.rb
Last active April 3, 2024 19:12
I imported my Jekyll from Squarespace's Wordpress XML with this
# coding: utf-8
require 'rubygems'
require 'hpricot'
require 'fileutils'
require 'safe_yaml'
require 'time'
module JekyllImport
# This importer takes a wordpress.xml file, which can be exported from your
@TJkrusinski
TJkrusinski / syntax.md
Created February 10, 2014 17:50
Syntax highlighting in keynote made easy

Keynote I guess pushed an update that doesn't take hightlighted code from xCode anymore. So, I googled around and found hightlight. It is a super useful utitlity to do syntax highlighting from the command line.

$ brew install hightlight

If you are on Mavericks you may need to brew link lua to get it working right.

Hightlight has support for all kinds of languages and themes and it can wrap the code with line numbers, which is great.

require 'mechanize'
require 'moving_average'
mechanize = Mechanize.new
login_page = mechanize.get 'https://www.myfitnesspal.com/account/login'
form = login_page.forms.first
# noinspection RubyResolve
form.field_with(id: 'username').value = "username"
form.field_with(id: 'password').value = "pass"
form.submit
@openmailbox
openmailbox / my_server.rb
Last active July 27, 2018 03:57
Introductory Rack-compliant web server
require 'socket'
require 'rack'
require 'sinatra'
# Simple, rack-compliant web server
class MyServer
STATUS_CODES = {
200 => 'OK',
500 => 'Internal Server Error'
}
@kotakanbe
kotakanbe / ipcalc.go
Created September 17, 2015 02:59
get all IP address from CIDR in golang
package main
import (
"net"
"os/exec"
"github.com/k0kubun/pp"
)
func Hosts(cidr string) ([]string, error) {
@cvan
cvan / HOWTO.md
Last active March 20, 2024 17:56
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you
@sultanqasim
sultanqasim / zram.sh
Created June 21, 2016 02:41
ZRAM config for Raspberry Pi 3
#!/bin/bash
# Raspberry Pi ZRAM script
# Tuned for quad core, 1 GB RAM models
# put me in /etc/init.d/zram.sh and make me executable
# then run "sudo update-rc.d zram.sh defaults"
modprobe zram
echo 3 >/sys/devices/virtual/block/zram0/max_comp_streams
echo lz4 >/sys/devices/virtual/block/zram0/comp_algorithm
@dtzitz
dtzitz / cart.exs
Last active August 30, 2016 21:56
# from ounce of elixir
#https://www.meetup.com/Women-Who-Code-Tampa/events/233014583/
ExUnit.start
defmodule CartTest do
use ExUnit.Case
test "starts with empty count" do
assert Cart.count_items([]) == 0
@wmakley
wmakley / install-ruby-1.8.7.sh
Last active October 7, 2021 09:41 — forked from silviorelli/gist:ad8e1d80bdc0245eb7e7
Install Ruby 1.8.7 on Mac OSX 10.12 Sierra with rbenv
#!/bin/sh
# The main issues with Ruby 1.8.7 are that it won't build with Clang,
# and the Net::HTTPS module won't work with modern versions of OpenSSL.
#
# This assumes you have already set up homebrew, and run: xcode-select --install
brew install homebrew/dupes/apple-gcc42
brew install libyaml libffi
brew install https://github.com/Homebrew/homebrew-versions/raw/586b7e9012a3ed1f9df6c43d0483c65549349289/openssl098.rb
export CC=/usr/local/bin/gcc-4.2