Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View napolux's full-sized avatar
🇮🇹
Hello from Italy!

Francesco Napoletano napolux

🇮🇹
Hello from Italy!
View GitHub Profile
@napolux
napolux / gist:796c120d7868e1749c09
Created February 25, 2015 15:19
Run iOS tests from shell, Xcode 6
# Running on iPhone 5s
xcodebuild test -scheme YOUR_PROJECT_NAME -destination 'platform=iOS Simulator,name=iPhone 5s'
@napolux
napolux / connect.js
Created September 29, 2015 18:08
Connecting to a Parrot Rolling Spider Drone with Node.js
'use strict';
var keypress = require('keypress');
var Drone = require('rolling-spider');
var colors = require('colors');
// Change this with your drone name...
var DRONE_NAME = 'RS_W123456';
if (ACTIVE && key) {
// Takeoff
if (key.name === 't') {
try {
d.takeOff(function() {
console.log('[INFO] Rolling Spider take-off completed'.green);
});
} catch(err) {
console.log('[ERROR] '.red + err.red);
}
@napolux
napolux / gist:4573698
Created January 19, 2013 17:06
Connection check in iOS: the simple way.
- (BOOL)connectedToNetwork {
NSURL* url = [[NSURL alloc] initWithString:@"http://google.com/"];
NSData* data = [NSData dataWithContentsOfURL:url];
if (data != nil)
return YES;
return NO;
}
#include <stdio.h>
int main()
{
printf("Hello, World!\n");
}
@napolux
napolux / man.c
Created April 17, 2016 17:59
Sega Saturn example code
/**************************************************************/
/* Trigger jumping if needed, also variable height jump logic */
Man_JumpTrigger()
{
if ( Man.JumpFudge )
{
Man.JumpFudge--;
}
curl http://w3.org/ -d "hello=world&foo=bar" --trace-ascii /dev/stdout
== Info: Trying 128.30.52.45...
== Info: Connected to w3.org (128.30.52.45) port 80 (#0)
=> Send header, 140 bytes (0x8c)
0000: POST / HTTP/1.1
0011: Host: w3.org
001f: User-Agent: curl/7.43.0
0038: Accept: */*
0045: Content-Length: 19
@napolux
napolux / google.java
Last active May 18, 2016 16:34
Google VS Oracle: 9 lines of code
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex+")");
if (fromIndex < 0)
throw new ArrayIndexOutOfBoundsException(fromIndex);
if (toIndex > arrayLen)
throw new ArrayIndexOutOfBoundsException(toIndex);
}
@napolux
napolux / speech.js
Last active July 7, 2016 05:35
speechSynthesis API for Google Chrome
var msg = new SpeechSynthesisUtterance();
var voices = window.speechSynthesis.getVoices();
msg.voiceURI = "native";
msg.text = "hello world";
msg.lang = "en-US";
window.speechSynthesis.speak(msg);
@napolux
napolux / time.php
Last active October 21, 2016 14:28
Measure execution time of PHP code
<?php
$start = microtime(true);
// Your code starts here
$i = 0;
while($i < 5000000) {
$i++;
}
// Your cord ends here