Skip to content

Instantly share code, notes, and snippets.

View mortenjust's full-sized avatar

Morten Just mortenjust

View GitHub Profile
@mortenjust
mortenjust / scrape.js
Created March 17, 2012 23:57 — forked from torgeir/scrape.js
Scraping with jsdom and jquery
/*
https://github.com/tmpvar/jsdom/tree/master/lib
$ curl http://www.timeanddate.com/norsk/kalender.html
(...)
<div id=po1 class=po></div>
<h1>Kalender for &#229;r 2011</h1>
<table class="ct" border="0" cellpadding="4" cellspacing="0" align="center">
(...)
$ node scrape.js
@mortenjust
mortenjust / proxy.php
Created March 18, 2012 12:57 — forked from therealklanni/proxy.php
Stupidly simple PHP proxy
<?php
// Stupidly simple PHP proxy for AJAX (HTTP GET) requests. Written by Kevin Lanni.
$dest = ''; // Set to the remote script URL (i.e. http://remotehost.com/some.php)
$a = array();
foreach ($_GET as $k=>$v) {
$a[] = "{$k}={$v}";
}
@mortenjust
mortenjust / app.yaml
Created March 28, 2012 10:49 — forked from darktable/app.yaml
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest
@mortenjust
mortenjust / reset.sass
Created May 5, 2012 12:20 — forked from trey/reset.sass
Eric Meyer's reset.css in Sass. Originally by @postpostmodern.
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain) */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
#!/usr/bin/python
# TODO make range command line arguments
import sys, codecs
sys.stdout = codecs.getwriter('utf-8')(sys.stdout) # if your terminal can't do utf-8, well...
import time
import urllib2
import BeautifulSoup
#!/usr/bin/python
# TODO make range command line arguments
import sys, codecs
sys.stdout = codecs.getwriter('utf-8')(sys.stdout) # if your terminal can't do utf-8, well...
import time
import urllib2
import BeautifulSoup
@mortenjust
mortenjust / ActivityA.java
Last active August 29, 2015 14:26
Stackoverflow answer, "Singleton in Android"
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@mortenjust
mortenjust / GridActivity.java
Last active August 29, 2015 14:27 — forked from gabrielemariotti/GridActivity.java
Android Wear: How to use a simple a GridViewPager with a FragmentGridPagerAdapter.
public class GridActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid);
final GridViewPager mGridPager = (GridViewPager) findViewById(R.id.pager);
mGridPager.setAdapter(new SampleGridPagerAdapter(this, getFragmentManager()));
}
@mortenjust
mortenjust / Note.java
Last active July 17, 2018 11:15 — forked from itsalif/SimpleXmlRequest.java
Volley adapter for making XML Requests. It uses Simple-XML for serializing XML to Objects (http://simple.sourceforge.net/). Code is based of GsonRequest. Hope someone finds it useful.
//
public class Note {
String to;
String from;
String heading;
String body;
}
@mortenjust
mortenjust / gist:8ab8eb3774a02ac27c7cefc0af5c5244
Created February 6, 2017 05:39 — forked from kerker00/gist:63d52c7b0e6a5df1d2bc
Self relaunch of Cocoa application (Swift version of https://gist.github.com/cdfmr/2204627)
let task = Process()
var args = [String]()
args.append("-c")
let bundle = Bundle.main.bundlePath
args.append("sleep 0.2; open \"\(bundle)\"")
task.launchPath = "/bin/sh"
task.arguments = args
task.launch()
NSApplication.shared().terminate(nil)