Skip to content

Instantly share code, notes, and snippets.

View shinigami1992's full-sized avatar
🌴
On vacation

Majid Mobini shinigami1992

🌴
On vacation
View GitHub Profile
@shinigami1992
shinigami1992 / INSTALL.rst
Created April 28, 2018 12:27 — forked from jensens/INSTALL.rst
sentry setup with docker-compose

In order to run this image do: docker-compose up -d to get all up. On first run DB initialization and initial user setup is done like so:

First start a bash in the container: docker-compose exec sentry /bin/bash. Then, inside bash, do sentry upgrade wait until it asks you for an inital user. When finished exit the bash.

When in doubt check with docker-compose ps if all went fine.

@shinigami1992
shinigami1992 / sw-test-cleaup.js
Created April 21, 2018 18:16 — forked from gauntface/sw-test-cleaup.js
Function to unregister SW and clear out old caches.
window.__testCleanup = () => {
const unregisterSW = () => {
return navigator.serviceWorker.getRegistrations()
.then((registrations) => {
const unregisterPromise = registrations.map((registration) => {
return registration.unregister();
});
return Promise.all(unregisterPromise);
});
};
@shinigami1992
shinigami1992 / nginx.conf
Created July 5, 2017 09:21 — forked from dnprock/nginx.conf
meteor nginx load balance with sticky session, used by vida.io
# Sticky session module for nginx
# https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/
# nginx configure command: ./configure --with-http_ssl_module --add-module=../nginx-sticky-module-ng/ --sbin-path=/usr/local/sbin --with-http_gzip_static_module
upstream vida_node_server {
sticky path=/;
server 127.0.0.1:3000 max_fails=3 fail_timeout=30s;
server [server2]:3000 max_fails=3 fail_timeout=30s;
}
@shinigami1992
shinigami1992 / resizer.py
Last active December 4, 2016 08:38
Recurisive image resizer
# sample usage:
# python resizer.py ./path ./resized 150
import PIL, sys, os
from PIL import Image
path = sys.argv[1]
path_resized = sys.argv[2]
base_width = int(sys.argv[3])
@shinigami1992
shinigami1992 / gist:85f24cc9b0ba6e3e78061ba6634171b6
Created November 25, 2016 20:52 — forked from etuttle/gist:bc1cd3814b984ec694d6
Assigning a MAC to docker0 in /etc/sysconfig/docker
# /etc/sysconfig/docker
#
# Other arguments to pass to the docker daemon process
# These will be parsed by the sysv initscript and appended
# to the arguments list passed to docker -d
other_args="--bridge=docker0"
DOCKER_CERT_PATH=/etc/docker
# Resolves: rhbz#1176302 (docker issue #407)
@shinigami1992
shinigami1992 / localStorageSync.js
Created May 2, 2016 08:38 — forked from akgupta/localStorageSync.js
Overriding backbone sync to use local storage
// overriding sync to use local storage when possible
sync : function(method, model, options){
var key, now, timestamp, refresh;
if(method === 'read' && this.constants.isStoredInLocalStorage) {
// only override sync if it is a fetch('read') request
key = this.getKey();
if(key) {
now = new Date().getTime();
timestamp = $storage.get(key + ":timestamp");
refresh = options.forceRefresh;
@shinigami1992
shinigami1992 / localStorage.js
Created May 1, 2016 06:10 — forked from brandonhall/localStorage.js
An example of overriding Backbone.sync and Backbone.parse to load data from localStorage in Backbone
// Overriding Backbone.sync to either load locally or from the server
sync: function(method, model, options) {
// Pull the key and stored object localStorage
var storageKey = localStorage.getItem('storage');
var storageData = localStorage.getItem('storage-' + storageKey);
// Apply the callback with our local data
if(storageData) {
options.success(JSON.parse(storageData));
@shinigami1992
shinigami1992 / MultipartFileSender
Created March 16, 2016 18:45 — forked from davinkevin/MultipartFileSender
Implementing HTTP byte-range requests in Spring 4 and other framework...
package lan.dk.podcastserver.utils.multipart;
import lan.dk.podcastserver.utils.MimeTypeUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@shinigami1992
shinigami1992 / logging.js
Created February 8, 2016 09:40
A simple node module that makes console.log/error/warn/debug statements log through winston (simply include at the beginning of your app)
'use strict';
var util = require('util'),
winston = require('winston'),
logger = new winston.Logger(),
production = (process.env.NODE_ENV || '').toLowerCase() === 'production';
module.exports = {
middleware: function(req, res, next){
console.info(req.method, req.url, res.statusCode);