Skip to content

Instantly share code, notes, and snippets.

class WebBrowser {
public:
// ...
void clearCache();
void clearHistory();
void removeCookies();
// ...
};
class WebBrowser {
@rightson
rightson / set-screen.sh
Created March 3, 2016 06:12
Add/set screen Full HD resolution on Ubuntu running in VMWare
#!/bin/sh
xrandr --newmode "1920x1080" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode Virtual1 1920x1080
xrandr --output Virtual1 --mode 1920x1080
@rightson
rightson / ping-overview.c
Created December 1, 2015 13:26
An overview of ping
// ping.c
int main()
{
// ...
main_loop(icmp_sock, packet, packlen);
}
// ping_common.c
void main_loop(int icmp_sock, __u8 *packet, int packlen)
{
@rightson
rightson / reference-member-is-dangerous.cpp
Last active October 22, 2015 06:30
Take care of your member reference variables
#include <iostream>
#include <string>
class Person {
public:
Person(std::string& reference): _reference(reference) {}
std::string name() { return _reference; }
private:
std::string &_reference;
};
# -*- coding: utf-8 -*-
import pycurl
from BeautifulSoup import BeautifulSoup
class BruteFrocePinterestCrawler:
def __init__(self):
self.content = ''
self.url = ''
# -*- coding: utf-8 -*-
class QuaternionNumber:
def __init__(self, r, i, j, k):
self.r = r
self.i = i
self.j = j
self.k = k
# -*- coding: utf-8 -*-
def cross_product(p1, p2, p3):
return ((p1[0] - p3[0]) * (p2[1] - p3[1])) - ((p2[0] - p3[0]) * (p1[1] - p3[1]))
def point_in_triangle(s, p1, p2, p3):
b1 = cross_product(s, p1, p2) < 0
b2 = cross_product(s, p2, p3) < 0
@rightson
rightson / app-controller-index.js
Created January 13, 2013 12:58
Alloy Controller Example (app-controller-index.js)
function doClick(e) {
alert($.label.text);
}
$.index.open();
@rightson
rightson / apps-views-index.xml
Last active December 11, 2015 01:19
Two-tabbed Alloy Application example (apps/views/index.xml)
<Alloy>
<Window class="container">
<Label id="label" onClick="doClick">Hello, World</Label>
</Window>
</Alloy>
@rightson
rightson / get_lat_lng_exif_pil.py
Created September 5, 2012 03:14 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)