Skip to content

Instantly share code, notes, and snippets.

View cloudscape-germany's full-sized avatar
🌥️
"I did write code in Java once, but that was the island in Indonesia" R.Stallman

Cloudscape Germany cloudscape-germany

🌥️
"I did write code in Java once, but that was the island in Indonesia" R.Stallman
View GitHub Profile
@cloudscape-germany
cloudscape-germany / geoip_usage.py
Created August 10, 2015 13:29
Maps GeoIP / Provider data to IP adresses
#!/usr/bin/python
import subprocess
import sys
import simplejson as json
import csv
from geoip import geolite2
from geoip import open_database
import pygeoip
geo_isp = pygeoip.GeoIP("GeoIPASNum.dat")
@cloudscape-germany
cloudscape-germany / myService.coffee
Created June 3, 2015 13:42
Full Code Example of uni testing Angular's $http module and its inherited q promises
'use strict'
angular.module('kreditorenApp').factory 'UserService', [
'$q', '$http', 'AuthService', '$state', '$alert'
($q, $http, AuthService, $state, $alert) ->
{
signIn: (user) ->
# verify form fill or other
if user.email != '' and user.password != ''
$http.post('/user/signin', user) # POST
# Avoiding the $http module's unchainable .success and .error promises
@cloudscape-germany
cloudscape-germany / jasmine-stub.coffee
Created June 3, 2015 13:12
Jasmine Stubbed Service
beforeEach ->
# Stub Dependencies for test isolation
myServiceMock = () ->
{
set: (entidy, value) ->
return
get: (entidy) ->
# mock
localStorageMock =
email : 'peter'
@cloudscape-germany
cloudscape-germany / $q_promises.coffee
Created June 2, 2015 10:23
Overide $http success promises with then-able promises Part 2
$http.get('https://api.github.com/users/peterbe/gists').then((response) ->
$scope.gists = response.data
return
).catch((response) ->
console.error 'Gists error', response.status, response.data
return
).finally ->
console.log 'finally finished gists'
return
@cloudscape-germany
cloudscape-germany / $http_original
Last active August 29, 2015 14:22
Overide $http success promises with then-able promises
$http.get('https://api.github.com/users/peterbe/gists').success((data) ->
$scope.gists = data
return
).error((data, status) ->
console.error 'Repos error', status, data
return
).finally ->
console.log 'finally finished repos'
return
describe 'AuthController Unit Tests', ->
# Load Module that contains controller
#
beforeEach angular.mock.module('kreditorenApp')
mockScope = undefined
$http = undefined
UserService = undefined
user = undefined
@cloudscape-germany
cloudscape-germany / syncthing.conf
Created April 8, 2015 22:35
.config/upstart/syncthing.conf
#
# Upstart Configuration File for Ubuntu 14.10 - to run syncthing
#
# Created 27 Dec 2014 - initial file written based on version from
# Syncthing forums here:
# https://forum.syncthing.net/t/keeping-syncthing-running-ubuntu-upstart/30
#
#
# BEFORE USE: change:
#
@cloudscape-germany
cloudscape-germany / gruntfile.js
Created March 16, 2015 12:35
Deployment with Grunt
grunt.initConfig({
sshconfig: {
awesome: {
host: 'awesome.tld',
port: '22',
privateKey: grunt.file.read(process.env['HOME'] + '/.ssh/id_rsa'),
username: 'ben',
agent: process.env.SSH_AUTH_SOCK
}
},
@cloudscape-germany
cloudscape-germany / nginx.conf
Created March 4, 2015 14:44
Proxy Pass with Nginx and node.js
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
@cloudscape-germany
cloudscape-germany / router.js
Created March 4, 2015 11:39
Re-wiring of Static Content due to HTML5 mode in Angular.js
'use strict';
var express = require('express');
module.exports = function(app) {
// Serve all asset files from necessary directories
//
var appPath = app.get('appPath')
app.use('/bower_components', express.static(appPath + "/bower_components/"));