Skip to content

Instantly share code, notes, and snippets.

View sasha7's full-sized avatar

Sasa Macakanja sasha7

View GitHub Profile
@sasha7
sasha7 / app.ts
Last active October 17, 2015 00:35
Angular 2 0.44 router example
import {provide, bootstrap} from 'angular2/angular2';
import {Component} from 'angular2/angular2';
import {CORE_DIRECTIVES} from 'angular2/angular2';
import {RouteConfig, ROUTER_DIRECTIVES, LocationStrategy, HashLocationStrategy, Location, RouterOutlet} from 'angular2/router';
import {ComponentA} from './componenta_folder/componenta';
import {ComponentB} from './componentb_folder/componentb';
import {ComponentC} from './componentc_folder/componentc';
@sasha7
sasha7 / NodoSocket.service.ts
Created November 23, 2015 13:15 — forked from joeherold/NodoSocket.service.ts
a sample implementation of socket.io in angular2 and typescript
/**!
* nodocms backend application
* Copyright(c) 2015 Johannes Pichler - webpixels
* Created by johannespichler on 23.11.15.
* LGPLv3.0 Licensed
**/
import {Injectable, provide} from 'angular2/core';
import {Observable} from 'rxjs';
const GEOLOCATION_ERRORS = {
'errors.location.unsupportedBrowser': 'Browser does not support location services',
'errors.location.permissionDenied': 'You have rejected access to your location',
'errors.location.positionUnavailable': 'Unable to determine your location',
'errors.location.timeout': 'Service timeout has been reached'
};
@sasha7
sasha7 / prezto-install.sh
Created March 13, 2016 06:39 — forked from kaplas/prezto-install.sh
Install prezto to a vagrant/*nix box with a single command
#!/bin/zsh
#
# This script installs prezto into a vagrant/*nix box which already has zsh and oh-my-zsh
# installed. It also replaces the prompt color and enables the git prezto module. If
# executed via the suggested command below, also the default shell is changed into zsh.
# BTW, if using this for a vagrant box, be sure to execute the command while ssh'd into
# the box.
#
# Usage: curl -L https://raw-gist-file-address-here.sh | zsh && chsh -s $(which zsh)
#
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 127.0.0.1:8010;
}
server {
{
"meta": {
"limit": 20,
"next": "/api/v1/likes/?offset=20&limit=20&format=json",
"offset": 0,
"previous": null,
"total_count": 101
},
"objects": [
{
@sasha7
sasha7 / nginx-mobile-redirect
Created August 25, 2016 09:25 — forked from dd-han/nginx-mobile-redirect
NGINX Mobile redirect
#with regex from http://detectmobilebrowsers.com/
#map suggestion via kolbyjack
#not tested
map $http_user_agent $mobile_agent{
default 0;
~* "android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino" 1;
~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibr
@sasha7
sasha7 / LICENSE
Created August 30, 2016 05:42 — forked from engelfrost/LICENSE
Fake localStorage. Useful for Safari Private Browsing and browsers that don't implement localStorage.
The MIT License (MIT)
Copyright (c) 2015 Textalk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@sasha7
sasha7 / fab deploy_static
Created August 30, 2016 14:38 — forked from drcongo/fab deploy_static
A Fabric task to deploy static assets to S3, gzipping the js and css files, and invalidating cache objects on CloudFront. Feel free to point out where it could be improved.
import datetime
import arrow
from fabric.api import *
import boto
from boto.cloudfront import CloudFrontConnection
import os
from datetime import date, timedelta
import gzip
import shutil
@sasha7
sasha7 / watchpack-ignore-node-modules.sh
Created August 30, 2016 21:04 — forked from aripalo/watchpack-ignore-node-modules.sh
Using webpack and its polling watch feature (via watchpack) can drain CPU which is due to watchpack polling all the npm deps within node_modules folder. This is a quick hack/fix until proper fix is merged & available in watchpack.
#!/bin/bash
# Should be used until https://github.com/webpack/watchpack/pull/23 is merged and available in npm
# See https://github.com/webpack/watchpack/issues/2#issuecomment-135204573 for more info
# Ensure we have npm
if ! hash npm 2>/dev/null; then
echo 'No NPM installed!'
exit 1
fi