Skip to content

Instantly share code, notes, and snippets.

View badgercl's full-sized avatar
🦡

Alfredo Cádiz badgercl

🦡
  • @crvshlab
  • Berlin, Germany
View GitHub Profile
@badgercl
badgercl / pi_server.md
Created August 23, 2017 23:40
Installing a PHP7 Webserver on a Raspberry Pi + NoIP + SSL
  1. sudo apt-get install apache2 -y
  2. sudo apt-get install apt-transport-https lsb-release ca-certificates
  3. wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
  4. echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
  5. sudo apt-get update
  6. sudo apt-get install apache2 php7.0 php7.0-curl php7.0-gd php7.0-json php7.0-mcrypt php7.0-mysql php7.0-opcache libapache2-mod-php7.0
  7. sudo a2dismod php5 (in case php5 is already installed)
  8. sudo a2enmod php7.0
  9. mkdir /home/pi/noip
  10. cd /home/pi/noip
@badgercl
badgercl / dispatch_main_queue.m
Created October 15, 2015 14:32
Dispatch on main thread (Objective-c)
#define bg_dispatch_main_async_safe(block)\
if ([NSThread isMainThread]) {\
block();\
} else {\
dispatch_async(dispatch_get_main_queue(), block);\
}
@badgercl
badgercl / Curl-cookie-headers
Created April 28, 2015 15:08
URL Headers including custom cookies
@badgercl
badgercl / android_launchers.sh
Created April 1, 2015 17:32
Script to create Android App icon assets
#!/bin/bash
#LDPI should be 36 x 36.
#MDPI should be 48 x 48.
#TVDPI should be 64 x 64.
#HDPI should be 72 x 72.
#XHDPI should be 96 x 96.
#XXHDPI should be 144 x 144.
#XXXHDPI should be 192 x 192.
@badgercl
badgercl / iOS-RandomStr
Created September 23, 2014 16:49
Generate random string from alphabet
NSString *vowels = @"abcdefghijlmnopqrstuvwxyz1234567890";
NSMutableString *str = [NSMutableString new];
for(int i=0; i<10; i++){
[str appendString:[vowels substringWithRange:NSMakeRange(arc4random_uniform([vowels length]), 1)]];
}
@badgercl
badgercl / ios-crash
Created July 11, 2014 18:40
Sometimes it's necessary to quick crash your iOS app
int *x = NULL; *x = 42;
SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
@badgercl
badgercl / osx-svg-to-png
Created February 20, 2014 02:55
[OSX] Convert SVG to PNG from CLI without external programs
qlmanage -t -s 1000 -o . picture.svg
@badgercl
badgercl / gist:7829547
Last active December 30, 2015 12:29
Runs code on the Android Application's main thread when no Activity is present (usually when using services)
final Context context_t = cntxt;
Handler mainHandler = new Handler(cntxt.getMainLooper());
Runnable locRunnable = new Runnable() {
@Override
public void run() {
// Code
}
};
mainHandler.post(locRunnable);