Skip to content

Instantly share code, notes, and snippets.

View pedemonte's full-sized avatar

Federico Pedemonte pedemonte

View GitHub Profile
@obscurerichard
obscurerichard / README.md
Created September 17, 2012 22:35
Simulates a low bandwidth, high-latency network connection

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency
slow dsl -b 1mbps         # Simulate DSL with a slower speed than the default

slow modem-56k -d eth0 # Simulate a 56k modem on the eth1 device. eth0 is unchanged.

@jarek-przygodzki
jarek-przygodzki / PostgreSQL.groovy
Created February 9, 2013 20:12
Howto connect to PostgreSQL DB in Groovy
import groovy.sql.Sql
def dbUrl = "jdbc:postgresql://localhost/test-db"
def dbUser = "test"
def dbPassword = "test"
def dbDriver = "org.postgresql.Driver"
def sql = Sql.newInstance(dbUrl, dbUser, dbPassword, dbDriver)
@msakamoto-sf
msakamoto-sf / start_jetty.groovy
Last active January 5, 2021 19:54
Jetty + GroovyServlet + Groovy Script = Start Jetty Anywhere !! You only need Groovy :)
@Grapes([
@Grab('org.eclipse.jetty.aggregate:jetty-all:8.1.10.v20130312'),
@Grab('com.h2database:h2:1.3.171'),
@Grab('javax.servlet:servlet-api:2.5'),
])
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.*
import org.eclipse.jetty.webapp.*
import javax.servlet.*
import javax.servlet.http.*
@espeed
espeed / HOTAIRBALLOON
Last active September 26, 2023 11:51
This is the first program I ever wrote... It was on the Commodore 64, and it displays a hot air balloon bouncing around the screen in 16 colors. I was probably 7 or 8. This program is the first example in the "C64 Programmers Reference Guide - Chapter 3: Programming Graphics on the Commodore 64" -- http://www.commodore.ca/manuals/c64_programmers…
10 REM SPRITE EXAMPLE 1...
20 REM THE HOT AIR BALLOON
30 VIC=13*4096:REM THIS IS WHERE THE VIC REGISTERS BEGIN
35 POKEVIC+21,1:REM ENABLE SPRITE 0
36 POKEVIC+33,14:REM SET BACKGROUND COLOR TO LIGHT BLUE
37 POKEVIC+23,1:REM EXPAND SPRITE 0 IN Y
38 POKEVIC+29,1:REM EXPAND SPRITE 0 IN X
40 POKE2040,192:REM SET SPRITE 0'S POINTER
180 POKEVIC+0,100:REM SET SPRITE 0'S X POSITION
190 POKEVIC+l, 100:REM SET SPRITE 0'S Y POSITION
@chilicat
chilicat / scp-ssh.gradle
Last active July 10, 2023 02:53
A simple gradle task to upload a file via SCP to a remote host and to execute a command via SSH on a remote host.
repositories { mavenCentral() }
configurations { sshAntTask }
dependencies { sshAntTask 'org.apache.ant:ant-jsch:1.9.2' }
ant.taskdef(
name: 'scp',
classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath: configurations.sshAntTask.asPath)
@ToastShaman
ToastShaman / SftpServiceTest.java
Created November 13, 2013 18:40
Using an embedded Apache MINA SSHD server in a unit test to verify that your code is able to upload a file through SFTP. This unit tests uses JSch as the client to speak to an embedded Apache MINA sftp server and verifies that the upload of a text file was successful.
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@mstaflex
mstaflex / Tornado webserver MJPEG streamer
Created November 24, 2014 11:23
Python Tornado webserver that streams JPEGs (in img/) as MJPEG-Stream using asynchronous timed callbacks (yields), being able to handly many different streams at the same time
import tornado.ioloop
import tornado.web
import gen
import time
import os
import tornado
file_list = os.listdir("img")
counter = 0
@t-oster
t-oster / MakeBraceletRingWithDroidScript
Created February 20, 2015 14:21
This DroidScript (JavaScript for Android) makes my China Bluetooth Bracelet Vibrate whenever I want.
var btn;
var bt;
var txt;
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
//Create a button 1/3 of screen width and 1/4 screen height.
@shimondoodkin
shimondoodkin / ThinBTClient.java
Last active September 16, 2022 15:02
android vibrate a vibrating bluetooth bracelet
/*
licence pubilc domain
prepered by Shimon Doodkin
vibrate a vibrating bluetooth bracelet
a simple bt client it sends "RING" AT command to a device named "BRACELET"
it is a good "android bluetooth client example".
@bhouse
bhouse / centos_nspawn.md
Created February 8, 2016 23:41
Centos 7.2.1511 via systemd-nspawn

Make a directory to install CentOS 7.2.1511 in

[root@localhost ~]# mkdir /centos_chroot

Make a directory for the rpm database

[root@localhost ~]# mkdir -p /centos_chroot/var/lib/rpm

Create the RPM database