Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / profile_ctx.py
Last active Jun 7, 2020 — forked from andriykohut/profile_ctx.py
[Python profiling context management] #python #profiling #performance
View profile_ctx.py
import cProfile
import contextlib
import io
import pstats
import sys
import timeit
@contextlib.contextmanager
def prof(*restrictions, stdout=True, dump=None, sortby='cumulative'):
View example.rb
# https://minhajuddin.com/2016/03/03/put-this-in-your-code-to-debug-anything
require 'rouge'
require 'method_source'
require 'pp'
class Dbg
def initialize(object, to:)
@object, @stream = object, to
end
@Integralist
Integralist / Faraday SSL example.rb
Last active Oct 13, 2015 — forked from mislav/gist:938183
Faraday SSL example
View Faraday SSL example.rb
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@Integralist
Integralist / Godofile.go
Last active Aug 29, 2015
Godo re-build task
View Godofile.go
// It's important to realise that you'll only ever want to `go build` or `go run` a single file
// This confused me originally
// I could understand why my task's `Context` didn't get passed the name of the changed file
// The problem was I was just hacking little scripts together
// In practice, you'll be working within a project directory and you'll have a single entry point file
package main
import . "gopkg.in/godo.v1"
@Integralist
Integralist / Makefile
Last active Sep 10, 2020 — forked from isaacs/Makefile
Example of a detailed Makefile
View Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
View 00_destructuring.md

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

@Integralist
Integralist / zsh.md
Last active Aug 29, 2015 — forked from jcleveley-zz/zsh.md
Zsh tips
View zsh.md

Path replacement

Moving from: /www/site1/media/css/main to /www/site2/media/css/main can be a pain, but not in zsh:

cd site1 site2
@Integralist
Integralist / ext.vim
Last active Feb 11, 2019 — forked from sjl/ext.vim
Some basic examples of executing external commands within Vim's COMMAND-LINE mode
View ext.vim
" run command
" no stdin
" output displayed in "Press enter to continue" style
" current buffer untouched
:!uptime
" run command
" pipe range of text to command on stdin
" output replaces the range in the current buffer
:RANGE!grep foo
@Integralist
Integralist / curry.js
Last active Aug 29, 2015 — forked from unscriptable/curry.js
Curry implementation in Node
View curry.js
module.exports = curry;
function curry (f) {
var arity = f.length;
var params = [];
var end = createEnd(f, arity);
return createCurried(params, arity, end);
}
function createEnd (f, arity) {
@Integralist
Integralist / duck typing rspec.rb
Last active Aug 29, 2015 — forked from cupakromer/gist:974c6fb9d0d6de3c2a6e
Test "Duck Typing" using RSpec 3's `instance_double`
View duck typing rspec.rb
class Calculator
def reduce(operator)
fail "You shouldn't be calling this directly!"
end
end
def uses_a_duck_type(calculation)
calculation.reduce(:+)
end
You can’t perform that action at this time.