Skip to content

Instantly share code, notes, and snippets.

View gustaflindqvist's full-sized avatar
🚴‍♂️
Focusing

Gustaf Lindqvist gustaflindqvist

🚴‍♂️
Focusing
View GitHub Profile
def check_ldap_user(name)
filter = Net::LDAP::Filter.eq("cn", name)
treebase = "dc=foo, dc=bar"
ldap.search(:base => treebase, :filter => filter, :attributes => attrs,
:return_result => false) do |entry|
entry.each do |attribute, values|
values.each do |value|
end
end
$("#current_form").submit(function(e){
// prevent submit
e.preventDefault();
console.log($(this).serialize());
// to submit the form again
$(this).submit();
});

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

# Install rvm system-wide
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib
@gustaflindqvist
gustaflindqvist / media-queries.scss
Created June 30, 2016 09:15 — forked from chrisjlee/media-queries.scss
All Media Queries breakpoints
@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 */ }
webpack --display-modules | awk '{print $3$4" "$2}' | grep -v bytes | sort -n | tail -100
@gustaflindqvist
gustaflindqvist / sticky.js
Created December 16, 2016 13:11 — 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
// Sticky Nav Component
var Sticky = (function() {
'use strict';
var CSS_CLASS_ACTIVE = 'is-fixed';
var Sticky = {
element: null,
position: 0,
addEvents: function() {
@gustaflindqvist
gustaflindqvist / keybindings.json
Created February 9, 2017 09:43
VSCode keybindings
[
{ "key": "cmd+shift+d", "command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus" },
{ "key": "cmd+shift+7", "command": "editor.action.commentLine",
"when": "editorTextFocus" }
]
@gustaflindqvist
gustaflindqvist / .bashrc
Created February 11, 2017 17:59
ssh-agent
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