Skip to content

Instantly share code, notes, and snippets.

View theShadow89's full-sized avatar
💻
In Code I Trust

Stefano Castoldi theShadow89

💻
In Code I Trust
  • AgileLab
  • Gorgonzola,Milan,Italy
View GitHub Profile
@theShadow89
theShadow89 / 0_reuse_code.js
Created August 2, 2014 10:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
package com.example.anothersignintest;
import java.io.IOException;
import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.gms.auth.GoogleAuthUtil;
import com.google.android.gms.auth.UserRecoverableAuthException;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
@theShadow89
theShadow89 / BrowseURL.java
Created November 29, 2013 16:51
Open Url in Browser
import java.awt.Desktop;
import java.net.URI;
class BrowseURL
{
public static void main(String args[]) throws Exception
{
// Create Desktop object
Desktop d=Desktop.getDesktop();
@theShadow89
theShadow89 / Singleton.java
Created November 21, 2013 10:24
Singleton
public class Singleton {
private static Singleton istanza = null;
//Il costruttore private impedisce l'istanza di oggetti da parte di classi esterne
private Singleton() {}
// Metodo della classe impiegato per accedere al Singleton
public static synchronized Singleton getSingleton() {
if (istanza == null)
istanza = new Singleton();
@theShadow89
theShadow89 / Domain.java
Created November 15, 2013 10:54
retrieve-an-top-level-domain-from-an-url-using-java
final InternetDomainName topPrivateDomain = InternetDomainName.from(uriHost).topPrivateDomain();
topPrivateDomain.name();
@theShadow89
theShadow89 / dump_db.sh
Created October 23, 2013 08:57
dump postgress file
pg_dump myDatabase --inserts -a -t table1 -t table2 > backup.sql;
pg_dump myDatabase --inserts -a -t seq1 -t seq2 > backupSequences.sql;
Parameters descriptions:
-a, --data-only dump only the data, not the schema
-t, --table=TABLE dump the named table(s) only
--inserts dump data as INSERT commands, rather than COPY
@theShadow89
theShadow89 / toUnicode.php
Last active December 17, 2015 00:58
This Function convert special character to Unicode. I used it for match the words on tweet.
<?php
function toUnicode($str) {
if (!mb_check_encoding($str, 'UTF-8')) {
trigger_error('String is not encoded in UTF-8');
return false;
}
return preg_replace_callback('/./u', function ($m) {
//convert the char on UTF-16 because the ord function not work very well on UTF-8
$s = mb_convert_encoding($m[0], 'UCS-2LE', 'UTF-8');
$ord = ord($s);