Skip to content

Instantly share code, notes, and snippets.

Avatar
🚴‍♂️
Focusing

Gustaf Lindqvist gustaflindqvist

🚴‍♂️
Focusing
View GitHub Profile
@gustaflindqvist
gustaflindqvist / touchevent.js
Created Mar 13, 2017
Solve touch position and works great inside iframes
View touchevent.js
var startY = 0;
var startX = 0;
document.addEventListener("touchstart", function (event) {
alert(11);
parent.window.scrollTo(0, 1);
startY = event.targetTouches[0].pageY;
startX = event.targetTouches[0].pageX;
});
document.addEventListener("touchmove", function (event) {
event.preventDefault();
View .bashrc
SSH_ENV=$HOME/.ssh/environment
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
View keybindings.json
[
{ "key": "cmd+shift+d", "command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus" },
{ "key": "cmd+shift+7", "command": "editor.action.commentLine",
"when": "editorTextFocus" }
]
@gustaflindqvist
gustaflindqvist / sticky.js
Created Dec 16, 2016 — forked from javierarques/sticky.js
Sticky Sideabr With Vanilla Javascript. Detects scroll and set fixed the element. Live example: http://codepen.io/javiarques/pen/vKdgjR
View sticky.js
// Sticky Nav Component
var Sticky = (function() {
'use strict';
var CSS_CLASS_ACTIVE = 'is-fixed';
var Sticky = {
element: null,
position: 0,
addEvents: function() {
View webpack-sorted-sizes.sh
webpack --display-modules | awk '{print $3$4" "$2}' | grep -v bytes | sort -n | tail -100
@gustaflindqvist
gustaflindqvist / media-queries.scss
Created Jun 30, 2016 — forked from chrisjlee/media-queries.scss
All Media Queries breakpoints
View media-queries.scss
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }
View sv.yml
# Det måste vara en tom rad här av någon anledning :)
sv:
date:
formats:
default: "%Y-%m-%d"
short: "%b %d"
long: "%B %d, %Y"
day_names: [Söndag, Måndag, Tisdag, Onsdag, Torsdag, Fredag, Lördag]
abbr_day_names: [Sön, Mån, Tis, Ons, Tors, Fre, Lör]
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
View AppDelegate.swift
var appToken = "<YOUR-APP-TOKEN>"
Lookback.setupWithAppToken(appToken)
var lookback: Lookback = Lookback()
lookback.shakeToRecord = true;
View can_destroy.rb
class ActiveRecord::Base
def can_destroy?
self.class.reflect_on_all_associations.all? do |assoc|
assoc.options[:dependent] != :restrict || (assoc.macro == :has_one && self.send(assoc.name).nil?) || (assoc.macro == :has_many && self.send(assoc.name).empty?)
end
end
end