Skip to content

Instantly share code, notes, and snippets.

View film42's full-sized avatar
✔️
Verified

Garrett Thornburg film42

✔️
Verified
View GitHub Profile
@eduncan911
eduncan911 / go-build-all
Last active April 11, 2024 07:14
Go Cross-Compile Script
#!/bin/bash
#
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
#
# To use:
#
# $ cd ~/path-to/my-awesome-project
# $ go-build-all
#
@rohanag12
rohanag12 / SslUtil.java
Last active April 5, 2024 16:28
Create an SslSocketFactory using PEM encrypted certificate files
/**
* Utility class to read encrypted PEM files and generate a
* SSL Socket Factory based on the provided certificates.
* The original code is by Sharon Asher (link below). I have modified
* it to use a newer version of the BouncyCastle Library (v1.52)
*
* Reference - https://gist.github.com/sharonbn/4104301"
*/
import org.bouncycastle.cert.X509CertificateHolder;
@l8nite
l8nite / gist:18e1aa073d4c758bf440
Created November 20, 2014 08:18
Quick and dirty way to exclude files from a gemspec
git_tracked_files = `git ls-files -z`.split("\x0")
gem_ignored_files = `git ls-files -i -X .gemignore -z`.split("\x0")
spec.files = git_tracked_files - gem_ignored_files
@noprompt
noprompt / slurp.clj
Created February 19, 2014 04:52
How to use slurp from ClojureScript
(ns foo.core
(:refer-clojure :exclude [slurp]))
(defmacro slurp [file]
(clojure.core/slurp file))
;; In CLJS
(ns bar.core
(:require [foo.core :include-macros true :refer [slurp]]))
private def getForecast:Try[JsValue] = {
val ts = date.getTime / 1000
val u = {
if (date == new Date()) new URL(s"https://api.forecast.io/forecast/$apiKey/$lat,$lon?units=$units")
else new URL(s"https://api.forecast.io/forecast/$apiKey/$lat,$lon,$ts?units=$units")
}
val s = new Scanner(u.openStream(), "UTF-8")
Try{s.useDelimiter("\\A").next().asJson}
}
@Kimundi
Kimundi / java_rust_generic.md
Last active March 20, 2024 06:02
A light comparison between Rust and Java generics and type system features.

Introduction

If you are familiar with Java's generics, and are coming to Rust, you might be lead to assume that its generics are working the same way.

However, due to the different type systems, and different implementation details, there are quite a few differences between generic code in both languages.

This document tries to give a short summary about those differences:

Core functionality

Java

@danneu
danneu / golang-vs-clojure-async.md
Last active November 6, 2023 04:09
Google I/O 2012 - Go Concurrency Patterns ported to Clojure Video: http://www.youtube.com/watch?v=f6kdp27TYZs
@philipbjorge
philipbjorge / Grammar__Grammar.py
Last active December 15, 2015 00:38
Empty Set Literal Notation for Python 2.7 [BUGFIX] Replaced minus sign with @ symbol. With the minus sign, Python couldn't handle any set notation that started with a negative (e.g. {-3} would fail).
# Grammar for Python
# Note: Changing the grammar specified in this file will most likely
# require corresponding changes in the parser module
# (../Modules/parsermodule.c). If you can't make the changes to
# that module yourself, please co-ordinate the required changes
# with someone who can; ask around on python-dev for help. Fred
# Drake <fdrake@acm.org> will probably be listening there.
# NOTE WELL: You should also follow all the steps listed in PEP 306,
@swannodette
swannodette / gist:3217582
Created July 31, 2012 14:52
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 18, 2024 10:01
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname