Skip to content

Instantly share code, notes, and snippets.

@jherrlin
jherrlin / gist:ce109d4f4ea0e633fb57
Created July 25, 2015 18:21
AngularJS / ui-router / ngResource
# app.js
angular.module('myApp', [
'ui.router',
'ngResource',
'services',
'factories',
'controllers'
class Car(object):
def __init__(self, color, gears): # This is the constructor with 2 arguments as input
self.color = color # This is object attribute
self.gears = gears
print('Color is : {}'.format(self.color)) # Prints when constructor is called
print('Number of gears: {}'.format(self.gears))
car1 = Car('Yellow', 5) # Create a new instance of Car
/*
DHCP-based IP printer
This sketch uses the DHCP extensions to the Ethernet library
to get an IP address via DHCP and print the address obtained.
using an Arduino Wiznet Ethernet shield.
Circuit:
Ethernet shield attached to pins 10, 11, 12, 13
In template:
<li><a href="{% url 'ProjectsListView'%}">Projects</a></li>
In urls.py
url(r'^$', ProjectsListView.as_view(), name='ProjectsListView'),
Genom att använda "name" i url så kan man koppla den urlen till en länk i templaten.
@jherrlin
jherrlin / Django-Admin-Honeypot-Test
Created December 18, 2015 20:03
Test after change of IPAddressField to GenericIPAddressField
py.test tests/ --cov admin_honeypot --cov-report term-missing --pep8 admin_honeypot
================================================================================ test session starts ================================================================================
platform darwin -- Python 2.7.10, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: /Users/nils/.virtualenvs/jherrlin-django1.9/lib/python2.7/site-packages/django-admin-honeypot, inifile: setup.cfg
plugins: cov-2.2.0, django-2.9.1, pep8-1.0.6
collected 17 items
tests/__init__.py .
tests/settings.py .
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>se.jherrlin</groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
d = {
'name': 'john',
'age': 30,
'city': 'Vaxjo'
}
for key, value in d.items():
print(key, value)
# Replace all
<script type="text/javascript">
function loadImageFileAsURL()
{
var filesSelected = document.getElementById("image").files;
var base64 = document.getElementById("base64");
if (filesSelected.length > 0)
{
var fileToLoad = filesSelected[0];
var fileReader = new FileReader();
import string
first = [i for i in range(7)]
second = ["{}{}".format(a,b) for a in string.ascii_uppercase for b in string.ascii_uppercase]
third = ['{}'.format(i).zfill(3) for i in range(10)]
big_list = []
for a in first:
function setup {
echo "Removing test container..."
rm -rf containers
echo "Git clone owtf valhalla containers"
git clone git@github.com:Kodkollektivet/owtf-valhalla-containers.git containers
printf "Creating virtual environment...\n\n"
virtualenv --python=/usr/bin/python venv