Skip to content

Instantly share code, notes, and snippets.

View learntoswim's full-sized avatar

Karl Stanton learntoswim

View GitHub Profile
@catalinbostan
catalinbostan / clear-net-ports.sh
Created September 8, 2017 11:10
Clears out port collisions for VMWare guests in Vagrant env.
#!/bin/bash
##
# Show the user what we're looking to remove from the network configs.
##
printf "\nWe've located the following entries matching the associated port argument. \n"
grep "add_nat_portfwd" /Library/Preferences/VMware\ Fusion/networking | grep $1
grep $1 /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf
##
@bradleyg
bradleyg / Dockerfile
Created October 26, 2016 12:46
Dockerfile for Wagtail on GAE
# docker build -t wagtail .
# docker run -it -v $(pwd):/app -p 0.0.0.0:8080:8080 wagtail
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python python-pip python-dev libmysqlclient-dev
ADD https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-131.0.0-linux-x86.tar.gz /tmp/cloudsdk.tar.gz
RUN tar -zxvf /tmp/cloudsdk.tar.gz -C /tmp
RUN /tmp/google-cloud-sdk/install.sh
@ezekielchentnik
ezekielchentnik / devServer.js
Last active August 2, 2016 21:51
webpack dev config with dev server, for react, latest greatest hot module reloading. Also uses postcss to compile our css (sass compatible), and image optimization
var WebpackDevMiddleware = require('webpack-dev-middleware');
var WebpackHotMiddleware = require('webpack-hot-middleware');
var historyApiFallback = require('connect-history-api-fallback');
var express = require('express');
var webpack = require('webpack');
var config = require('./webpack.config.dev');
var app = express();
var compiler = webpack(config);
@sevastos
sevastos / docker-mongo-virtualbox.md
Last active December 3, 2022 10:11
Boot2Docker (VirtualBox) MongoDB volume filesystem issue

Journey

I was using Boot2Docker 1.2 (OSX) and wanted to use volume for MongoDB. First nothing was happening because 1.2 has no Guest Additions and volumes don't work. There is a workaround by making a boot2docker.iso from master which has Guest Additions.

But then Mongo didn't like putting data on VirtualBox's shared folders:

[initandlisten] 	WARNING: This file system is not supported. For further information see:
[initandlisten] http://dochub.mongodb.org/core/unsupported-filesystems
@eliangcs
eliangcs / pyenv+virtualenv.md
Last active June 8, 2023 07:46
Cheatsheet: pyenv, virtualenvwrapper, and pip

Cheatsheet: pyenv, virtualenvwrapper, and pip

Installation (for Mac OS)

Install pyenv with brew

brew update
brew install pyenv
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
function onlyStatic (middleware) {
return function (req, res, next) {
var match = /(\.css|\.eot|\.gif|\.html|\.js|\.png|\.svg|\.ttf|\.woff|\.jpg)($|\?.*$)/ig.exec(req.originalUrl);
if (!match) return next();
middleware(req, res, next);
};
}
//usage
this.use(onlyStatic(express.static(__dirname + "/public")));
// Timer to continue counting while using bcrypt.
// Demonstrates that the bcrypt functions are asynchronous.
;(function() {
console.log('start timer');
var x = 1;
setInterval(function() {
console.log('Timer: ' + x);
x++;
}, 1000);
}());
@Integralist
Integralist / Description.md
Last active April 25, 2020 16:20
This is how BBC News currently implements it's Image Enhancer for responsive images. Note: this is a completely rebuilt version of the code so the BBC's original source code doesn't actually look anything like the below example.

The BBC has a server-side image service which provides developers with multiple sized versions of any image they request. It works in a similar fashion to http://placehold.it/ but it also handles the image ratios returned (where as placehold.it doesn't).

The original BBC News process (and my re-working of the script) follows roughly these steps...

  • Create new instance of ImageEnhancer
  • Change any divs within the page (which have a class of delayed-image-load) into a transparent GIF using a Base64 encoded string.
    • We set the width & height HTML attributes of the image to the required size
    • We know what size the image needs to be because each div has custom data-attr set server-side to the size of the image
    • We then set a class of image-replace onto each newly created transparent image
  • We use a 250ms setTimeout to unblock the UI thread and which calls a function resizeImages which enhances the image-replace images so their source is now set to a URL whe
@webgio
webgio / app.coffee
Last active December 10, 2023 10:24
Marionette.js module to manage authentication. Needs a server method that checks credentials returning true or false. Started from this blog post code: http://clintberry.com/2012/backbone-js-apps-authentication-tutorial/
App = new Marionette.Application();
App.addRegions {
"headerRegion": "#header"
"topMenuRegion": "#top-menu"
"mainRegion" : "#main"
}
App.on 'initialize:after', ->
Backbone.history.start()