This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app.js | |
angular.module('myApp', [ | |
'ui.router', | |
'ngResource', | |
'services', | |
'factories', | |
'controllers' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What i wanna do: | |
- Get all repos from a github organization. | |
- Save them to the database. | |
- Get all contributors from the repos that we just stored in the database. | |
- Create a two way relationship Contributor <-> Project | |
# Models.py | |
class Project(TimeStampedModel): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the working sketch | |
// THIS IS THE WORKING ONE!! | |
// With ESP8266 | |
#include <OneWire.h> | |
#include <DallasTemperature.h> | |
#include <SoftwareSerial.h> | |
#define ONE_WIRE_BUS 3 | |
#define SSID "network" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d = { | |
'name': 'john', | |
'age': 30, | |
'city': 'Vaxjo' | |
} | |
for key, value in d.items(): | |
print(key, value) | |
# Replace all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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(); |
OlderNewer