Skip to content

Instantly share code, notes, and snippets.

View danielberkompas's full-sized avatar

Daniel Berkompas danielberkompas

View GitHub Profile
@danielberkompas
danielberkompas / .gitconfig
Last active February 10, 2021 23:48
Git Cheat Sheet
# Use these aliases in your gitconfig for awesomeness
# You can use them like so:
# git lg -> prettier logs
# git s -> "git status"
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
s = status -s
@danielberkompas
danielberkompas / auth.ex
Created March 4, 2017 20:44
An example of how to hack together Ueberauth.Auth structs
defmodule MyApp.Auth do
@moduledoc """
Creates `Ueberauth.Auth` structs from OAuth responses.
This module is an ugly hack which is necessary because `Ueberauth` doesn't provide
the necessary hooks to get such a struct without giving it control of the whole
callback phase. We can't do this in the API because all the mobile app can give us
is the OAuth token.
Most of the code was lifted from Ueberauth, with minor changes as needed.
@danielberkompas
danielberkompas / scheduler.ex
Created October 26, 2016 17:59
A simple mix task scheduler for Elixir apps
defmodule MyApp.Scheduler do
@moduledoc """
Schedules a Mix task to be run at a given interval in milliseconds.
## Options
- `:task`: The name of the Mix task to run.
- `:args`: A list of arguments to pass to the Mix task's `run/1` function.
- `:interval`: The time interval in millisconds to rerun the task.
@danielberkompas
danielberkompas / deploy.rb
Last active December 1, 2018 23:40
A deployment script for Ruby/Rails on Heroku. Includes automatic running of migrations, custom branches and custom remotes.
# -----------------------------------------------------
# Ruby/Rails Heroku Deployment Script
# @author Daniel Berkompas
#
# After downloading, run `ruby deploy.rb --help` to
# get usage instructions.
#
# MIT License
# -----------------------------------------------------
require 'optparse'
@danielberkompas
danielberkompas / destructure.ex
Created October 31, 2016 20:26
Javascript-style Destructuring for Elixir
defmodule Destructure do
@moduledoc """
Provides helpers for destructuring Elixir data structures. See the `d/1` macro
for more information.
"""
@doc """
Easy destructuring of maps and keyword lists, with atom keys only.
## Examples
@danielberkompas
danielberkompas / problem.html
Created March 30, 2014 02:47
This is my problem
<html data-ember-extension="1"><head><script type="text/javascript" async="" src="https://d2rcp9ak152ke1.cloudfront.net/assets/javascripts/squatch.min.js"></script><script type="text/javascript" async="" src="https://cdn.heapanalytics.com/js/heap.js"></script><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
<!-- iOS Home Screen Icons -->
<link rel="apple-touch-icon" sizes="57x57" href="/assets/mentor/lead_simple_mark_ios_57.png">
<link rel="apple-touch-icon" sizes="72x72" href="/assets/mentor/lead_simple_mark_ios_72.png">
<link rel="apple-touch-icon" sizes="114x114" href="/assets/mentor/lead_simple_mark_ios_114.png">
<link rel="apple-touch-icon" sizes="144x144" href="/assets/mentor/lead_simple_mark_ios_144.png">
<!-- jQuery -->
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
# configuration for osx clipboard support
set-option -g default-command "reattach-to-user-namespace -l sh"

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
def pbcopy(str)
IO.popen('pbcopy', 'r+') {|io| io.puts str }
output.puts "-- Copy to clipboard --\n#{str}"
end
Pry.config.commands.command "hiscopy", "History copy to clipboard" do |n|
pbcopy _pry_.input_array[n ? n.to_i : -1]
end
Pry.config.commands.command "copy", "Copy to clipboard" do |str|