Skip to content

Instantly share code, notes, and snippets.

@johncant
johncant / -var-log-apache2-error.log
Created February 22, 2016 11:03
Owncloud server borkage
[Sun Feb 21 08:04:07 2016] [error] [client 2.96.46.136] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 5251072 bytes) in /usr/share/owncloud/lib/private/files/storage/local.php on line 161
[Sun Feb 21 08:18:11 2016] [error] [client 2.96.46.136] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 5251072 bytes) in /usr/share/owncloud/lib/private/files/storage/local.php on line 161
[Sun Feb 21 08:19:54 2016] [error] [client 2.96.46.136] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 5251072 bytes) in /usr/share/owncloud/lib/private/files/storage/local.php on line 161
[Sun Feb 21 09:07:54 2016] [error] [client 2.96.46.136] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 5251072 bytes) in /usr/share/owncloud/lib/private/files/storage/local.php on line 161
[Sun Feb 21 09:52:32 2016] [error] [client 2.96.46.136] PHP Fatal error: Allowed memory size of 536870912 bytes
@johncant
johncant / comcast.js
Created November 19, 2015 12:24 — forked from Jarred-Sumner/comcast.js
Comcast injects this into webpages to show copyright notices
// Comcast Cable Communications, LLC Proprietary. Copyright 2014.
// Intended use is to display browser notifications for critical and time sensitive events.
var _ComcastAlert = (function(){
return {
SYS_URL: '/e8f6b078-0f35-11de-85c5-efc5ef23aa1f/aupm/notify.do'
, dragObj: {zIndex: 999999}
, browser: null
, comcastCheck: 1
, comcastTimer: null
, xmlhttp: null
/*******************************************************
* USB-ISS test application for Linux. *
* *
* Sets USB-ISS into spi mode and reads and writes from *
* microchips 23k256 *
* *
* Compiled using gcc, tested on Ubunto 10.4 LTS. *
* *
* By James Henderson, 2012. *
*******************************************************/
@johncant
johncant / tube.py
Last active August 29, 2015 14:24 — forked from matteo-pacini/tube.py
##!/usr/bin/env python3
#
#import urllib.request
#
## Read XML from TFL website
#
#url = 'http://cloud.tfl.gov.uk/TrackerNet/LineStatus'
#response = urllib.request.urlopen(url)
#xml = response.read().decode('utf-8')
#
@johncant
johncant / hs.hs
Created April 9, 2015 22:34
Hacky way of returning values from GHCJS callbacks to JavaScript [SUCCESS]
import GHCJS.Foreign
import GHCJS.Types
foreign import javascript "js_testFunc" js_testFunc :: JSFun (JSString -> JSFun (JSString -> IO ()) -> IO () ) -> IO ()
foreign import javascript "js_callCallback" js_callCallback :: JSFun (JSString -> IO ()) -> JSString -> IO ()
main :: IO ()
main = do
js_testFunc =<< syncCallback2 AlwaysRetain True (\passedIn returner -> do
putStrLn $ fromJSString passedIn
@johncant
johncant / hs.hs
Created April 9, 2015 19:34
GHCJS call callback synchronously [FAIL]
import GHCJS.Foreign
import GHCJS.Types
data DontTouchThis
foreign import javascript "js_testFunc" js_testFunc :: JSFun (JSRef DontTouchThis -> IO JSString) -> IO ()
main :: IO ()
main = js_testFunc =<< syncCallback1 AlwaysRetain True (\_ -> putStrLn "bar" >> return (toJSString "quux"))
@johncant
johncant / write_sd_image
Created March 21, 2015 18:15
Use rooted Android phone to write Raspberry Pi image to microSSD card
#!/bin/bash
# Use a rooted android phone to load a raspberry pi image onto a microSSD card.
#
# adb push /dev/block/$PHONEBLOCKDEVICE
# won't work because you are not root by default
#
# Commands like
# cat $IMAGEFILE | adb su -c dd of=/dev/block/$PHONEBLOCKDEVICE
# won't work because adb corrupts the stream
#
@johncant
johncant / Vagrantfile
Last active August 29, 2015 14:14
GHC 7.8.4, Cabal 1.22, Haskell, Snap, Haste and React on Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
@johncant
johncant / main.hs
Created May 9, 2014 14:31
Use OpenGL 3.2 shaders and GLUT in Haskell
{-# LANGUAGE CPP #-}
-- it draws a triangle.
import Graphics.UI.GLUT
import Graphics.Rendering.OpenGL
import Foreign.Marshal.Array
import Foreign.Storable
import Foreign.Ptr
import qualified Data.ByteString as B
load "brain1_denoised.mat"
% test signals
%
%result = zeros(1, 512);
%result = sin(2*pi*(1:2048)*20/512) + cos(2*pi*(1:2048)*6/512);
result = (result-mean(result))/max(result);
printf("Denoised brain data loaded\n");