Skip to content

Instantly share code, notes, and snippets.

@massimomusante
massimomusante / listen-4-shutdown.sh
Created Jun 3, 2018
Listen for shutdown shell script
View listen-4-shutdown.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: listen-for-shutdown.py
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
@massimomusante
massimomusante / listen-4-shutdown.py
Last active Jun 3, 2018
Raspberry PI listen for shutdown script
View listen-4-shutdown.py
#!/usr/bin/env python
import RPi.GPIO as GPIO
import subprocess
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
View fragment-01-db-initialization.java
protected final static String DBPATH = "./localdb";
protected GraphDatabaseService db = null;
protected void startup()
{
// instantiate the database
db = new GraphDatabaseFactory().newEmbeddedDatabase(DBPATH);
View AndEngineActivity.java
package com.musante.demo.demoandengine;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.util.FPSLogger;
import org.andengine.ui.activity.SimpleBaseGameActivity;
@massimomusante
massimomusante / DemoSprite1.java
Created Apr 25, 2013
More code fragments for Slick2d blog post
View DemoSprite1.java
...
private int x = 100;
private int y = 100;
private int dx = 1;
private int dy = 1;
private Image img = null;
...
@massimomusante
massimomusante / DemoHello1.java
Created Apr 25, 2013
Code fragments for Slick2d Blog post
View DemoHello1.java
...
g.drawString("Hello There!", 100, 100);
...
@massimomusante
massimomusante / DemoSprite.java
Created Apr 25, 2013
Bouncing ball Slick2D demo
View DemoSprite.java
package com.musante.demo;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
/**
@massimomusante
massimomusante / DemoHello.java
Created Apr 25, 2013
Bouncing hello-world Slick2d demo
View DemoHello.java
package com.musante.demo;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
/**
* Slick Hello-world demo
@massimomusante
massimomusante / test1.scad
Last active Dec 14, 2015
Some OpenSCAD examples
View test1.scad
translate([-375,-375,-250])
{
cube([750,750,25]);
translate([0,0,525])
cube([750,750,25]);
translate([0,0,240])
cube([750,750,25]);
@massimomusante
massimomusante / exploring-sensors-1.java
Created Nov 12, 2012
Android sensor explorer (fragments)
View exploring-sensors-1.java
public class SensorsActivity extends Activity implements SensorEventListener, OnItemSelectedListener
{
...
}