Skip to content

Instantly share code, notes, and snippets.

View un33k's full-sized avatar
🎯
Focusing

Val N. un33k

🎯
Focusing
View GitHub Profile
@ProjectCheshire
ProjectCheshire / Auto.py
Last active August 16, 2020 13:19
Autoschemer.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)
@un33k
un33k / app.js
Created April 24, 2014 01:45 — forked from amineeg/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 June 10, 2019 14:26
AngularJS: Setting up a mocked service to use in controller unit tests.
// Mocked Service
angular.module('mock.users', []).
factory('UserService', function($q) {
var userService = {};
userService.get = function() {
return {
id: 8888,
name: "test user"
}
# 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 July 30, 2012 20:47
saltstack on lenny
#!/bin/sh
#
# Salt master
###################################
# LSB header
### BEGIN INIT INFO
# Provides: salt-master
# Required-Start: $remote_fs $network
@peterbe
peterbe / gist:2913338
Created June 11, 2012 23:13
A very practical decorator for Django Class Based Views
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 February 24, 2012 13:20
State of states module for salt (saltstack)
"""
State module
============
The state module for logical union of several states.
Available Functions
-------------------
@garnaat
garnaat / s3_website.py
Created February 18, 2011 02:12
Sample script for creating a website in an S3 bucket with boto
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 November 18, 2010 02:24
call Wikipedia API using jQuery and parse result
<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);