Skip to content

Instantly share code, notes, and snippets.

View cstrap's full-sized avatar
🐍

Christian Strappazzon cstrap

🐍
View GitHub Profile
/*
* Android API Guide
* http://developer.android.com/guide/topics/ui/actionbar.html
* Android Design Guide
* http://developer.android.com/design/patterns/actionbar.html
* Titanium Mobile will support someday
* https://jira.appcelerator.org/browse/TIMOB-2371
*/
var osName = Ti.Platform.osname,
isAndroid = osName==='android',
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@cstrap
cstrap / JavaMergeListFiles
Last active August 29, 2015 14:04
Merge a list of files into another one
/**
* Merge a list of files into another one
*
* @param files
* @param mergedFile
* @throws IOException
*/
public static void mergeFiles(List<File> files, File mergedFile) {
if (mergedFile.exists()) {
@cstrap
cstrap / JavaGzipFile
Last active August 29, 2015 14:04
Gzip file in java
public static void gzipFile(String source, String destination, boolean delete) {
try {
FileInputStream fis = new FileInputStream(source);
FileOutputStream fos = new FileOutputStream(format("%s.gz", destination));
GZIPOutputStream gzipOS = new GZIPOutputStream(fos);
byte[] buffer = new byte[1024];
int len;
@cstrap
cstrap / RESTClient.java
Created September 19, 2014 12:16
Example of REST client with POST data
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RESTClient {
@cstrap
cstrap / gist:d7cd401203ee680292ad
Created September 19, 2014 12:18
Get data from JSON with a regex
/*
* (value) could be (value|tag|name) or whatever is the key on json string
*/
public static String getValueFromJson(String json) {
String value = "";
Pattern p = Pattern.compile("\"(value)\":\"((\\\\\"|[^\"])*)\"");
Matcher m = p.matcher(json);
if (m.find() && m.groupCount() > 1) {
@cstrap
cstrap / add_subnet_vertica
Created October 6, 2014 09:43
Adding a HP Vertica node outside main cluster
-- First setup Vertica node.
-- When it's up'n'running launch from vsql:
CREATE SUBNET my_subnet with '192.168.0.0'; -- IP of your subnet may differs
-- The above statement creates a subnet between Vertica main clusters and the Vertica node.
-- NOTE: they must be in the same network
ALTER DATABASE VERTICA_DB EXPORT ON my_subnet;
@cstrap
cstrap / enable_spill_vertica
Created October 6, 2014 09:46
HP Vertica - Server with low memory - Enable Spill
When: ERROR: Join inner did not fit in memory ...
$ vsql
dbadmin=> select set_vertica_options('EE','ENABLE_JOIN_SPILL');
set_vertica_options
--------------------------------------------------------------
EE Vertica Options
--------------------
@cstrap
cstrap / mailtrap.py
Created March 17, 2015 15:34
Integrate mailtrap.io - plain python
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('There was a terrible error that occured and I wanted you to know!')
msg['Subject'] = 'Hello world'
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
username = 'mailtrap.io username'
password = 'mailtrap.io password'