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: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;
}
@napolux
napolux / StringEncryption.php
Last active January 8, 2022 16:55
Simple reversible encryption
<?php
// From a StackOverflow answer...
// I can't find the original link :-(
class StringEncryption {
const ENCRYPTION_KEY = "She's a killer queeeeeeeeen!";
public function encode($url = '') {
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(self::ENCRYPTION_KEY), $url, MCRYPT_MODE_CBC, md5(md5(self::ENCRYPTION_KEY))));
}
@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);
}
#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 / install.sh
Created May 1, 2016 18:25
Come installare Let's Encrypt su un virtualhost apache su una macchina ubuntu hostata da DigitalOcean
# Installa git
sudo apt-get update
sudo apt-get install git
# Clona il repo di letsencrypt.org
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# Crea il certificato per il tuo dominio
cd /opt/letsencrypt
./letsencrypt-auto --apache -d tuodominio.it
@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);
}