Skip to content

Instantly share code, notes, and snippets.

Val Neekman un33k

View GitHub Profile
@ProjectCheshire
ProjectCheshire / Auto.py
Last active May 23, 2018
Autoschemer.py
View Auto.py
import os
import importlib
from inspect import getmembers, isclass
from graphene import ObjectType
from logzero import logger
def schema_operations_builder(operationName, operationModule, operationBase, clsName):
op_base_classes = build_base_classes(operationName, operationModule, operationBase, clsName)
View app.js
'use strict';
// Declare app level module which depends on filters, and services
var app= angular.module('myApp', ['ngRoute']);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'loginCtrl'});
$routeProvider.otherwise({redirectTo: '/login'});
}]);
@alicial
alicial / mock-service-example.js
Last active Jun 10, 2019
AngularJS: Setting up a mocked service to use in controller unit tests.
View mock-service-example.js
// Mocked Service
angular.module('mock.users', []).
factory('UserService', function($q) {
var userService = {};
userService.get = function() {
return {
id: 8888,
name: "test user"
}
View model_cache.py
# The author disclaims copyright to this source code. In place of a legal
# notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
import hashlib, cPickle as pickle, logging
from django.db.models import signals as db_signals
from django.core.cache import cache
@justone
justone / salt-master
Created Jul 30, 2012
saltstack on lenny
View salt-master
#!/bin/sh
#
# Salt master
###################################
# LSB header
### BEGIN INIT INFO
# Provides: salt-master
# Required-Start: $remote_fs $network
@peterbe
peterbe / gist:2913338
Created Jun 11, 2012
A very practical decorator for Django Class Based Views
View gist:2913338
from django.utils.decorators import method_decorator
def class_decorator(decorator):
def inner(cls):
orig_dispatch = cls.dispatch
@method_decorator(decorator)
def new_dispatch(self, request, *args, **kwargs):
return orig_dispatch(self, request, *args, **kwargs)
cls.dispatch = new_dispatch
return cls
@sirkonst
sirkonst / states.state.py
Created Feb 24, 2012
State of states module for salt (saltstack)
View states.state.py
"""
State module
============
The state module for logical union of several states.
Available Functions
-------------------
@garnaat
garnaat / s3_website.py
Created Feb 18, 2011
Sample script for creating a website in an S3 bucket with boto
View s3_website.py
import time
import boto
from boto.s3.connection import Location
#
# create a couple of strings with our very minimal web content
#
index_html = """
<html>
<head><title>My S3 Webpage</title></head>
@steren
steren / index.html
Created Nov 18, 2010
call Wikipedia API using jQuery and parse result
View index.html
<div id="insertTest"></div>
<script>
var wikipediaHTMLResult = function(data) {
var readData = $('<div>' + data.parse.text.* + '</div>');
// handle redirects
var redirect = readData.find('li:contains("REDIRECT") a').text();
if(redirect != '') {
callWikipediaAPI(redirect);
You can’t perform that action at this time.