Skip to content

Instantly share code, notes, and snippets.

View magnusdahlstrand's full-sized avatar

Magnus Dahlstrand magnusdahlstrand

View GitHub Profile

Keybase proof

I hereby claim:

  • I am magnusdahlstrand on github.
  • I am magnus (https://keybase.io/magnus) on keybase.
  • I have a public key whose fingerprint is 462F F191 9AFD EF1E CEE8 BD80 C30C BBD9 39B4 3536

To claim this, I am signing this object:

@magnusdahlstrand
magnusdahlstrand / apache.conf
Created January 10, 2017 19:05
nginx configuration to forward requests to apache if there's no nginx server block handling the specific request
server {
listen 8999 default_server;
server_name _;
location / {
# return 418; #teacup for test
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
MidiIn min;
MidiOut mou;
MidiMsg msg;
2 => int input_device;
1 => int output_device;
if( me.args() ) me.arg(0) => Std.atoi => input_device;
if( me.args() ) me.arg(1) => Std.atoi => output_device;

BEM

Know your element (__) from your modifier (--). Both blocks and elements can have modifiers. (.b--m, .b__e--m).

In react lingo, BEM's "B" (for "Block") is a component.

Elements can nest deep in html, but the selector doesn't represent this deep nesting. (no .a__b__c, instead just .a__c - which can be in .a__b).

The idea The idea with BEM is to keep a flat hierarchy (don't nest selectors) with simple selectors - only one class per selector, and no IDs or element tags. By not nesting we have a low and consistent specificity of all html elements, which makes it possible to have modifications of styles without using !important.

@magnusdahlstrand
magnusdahlstrand / git-permalink-oneliner-explanation.md
Last active August 29, 2015 14:03
git permalink oneliner breakdown
@magnusdahlstrand
magnusdahlstrand / commands.bash
Created September 6, 2013 18:14
Example of how r.js can break css src url declarations by removing quotemarks
r.js -o cssIn=flat.css out=flat_result.css
r.js -o cssIn=import.css out=import_result.css
@magnusdahlstrand
magnusdahlstrand / Gruntfile
Created July 19, 2013 11:43
Quick and dirty nodejs s3 sync from gruntfile. Not 100% yet
require('js-yaml');
var _ = require('lodash');
var fs = require('fs');
var aws = require('aws-sdk');
var path = require('path');
var exec = require('exec-sync');
module.exports = function (grunt) {
grunt.initConfig({
@magnusdahlstrand
magnusdahlstrand / imgcmprs.sh
Last active December 15, 2015 09:29
Simple png/jpg -> optimised jpg script
#!/usr/bin/env bash
function cleanup() {
rm -rf "$temp_dir" > /dev/null 2>&1
}
trap cleanup EXIT
function setup() {
temp_dir='/tmp/imgcmprs'
@magnusdahlstrand
magnusdahlstrand / ExportDocsAsPNGs.jsx
Created February 28, 2013 16:57
Illustrator script to export open documents to 24-bit PNG files.
function main() {
if (app.documents.length) {
var outputDir = Folder.selectDialog('Select output folder.', '~');
if (outputDir) {
for (var i = 0; i < app.documents.length; i++) {
doc = app.documents[i];