Skip to content

Instantly share code, notes, and snippets.

@erlangparasu
erlangparasu / nginx.conf
Created December 20, 2018 07:16 — forked from ashleydw/nginx.conf
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;
@erlangparasu
erlangparasu / gist:7fb605eb3fb7fd02a1bd79b17df9f310
Created December 18, 2018 00:31 — forked from simonw/gist:92481
Compile nginx standalone without root access
# Compile nginx standalone without root access
mkdir ~/installed
mkdir ~/installed/nginx
mkdir ~/src
cd ~/src
# PCRE dependency - we'll compile against this statically
wget http://kent.dl.sourceforge.net/sourceforge/pcre/pcre-7.8.tar.gz
tar -xzvf pcre-7.8.tar.gz
@erlangparasu
erlangparasu / Autostart.java
Created December 8, 2018 14:20 — forked from chandruark/Autostart.java
used to get Autostart option for Alarm Manager in Android
private void addAutoStartupswitch() {
try {
Intent intent = new Intent();
String manufacturer = android.os.Build.MANUFACTURER .toLowerCase();
String model= Build.MODEL;
Log.d("DeviceModel",model.toString());
switch (manufacturer){
case "xiaomi":
web: node web.js
worker: node worker.js
clock: node clock.js
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
Log.d(TAG, "onCreate: INSTALLED GOOGLE PLAY VERSION: "
+ getPackageManager()
.getPackageInfo("com.google.android.gms", 0).versionName);
} catch (PackageManager.NameNotFoundException e) {
@erlangparasu
erlangparasu / currencies.json
Created June 22, 2018 22:03 — forked from mlvea/currencies.json
Common currencies as an array
[
{
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@erlangparasu
erlangparasu / Common-Currency.json
Created June 22, 2018 22:02 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i + 1), 16));
}
return data;
}
// Ref: https://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java/140861#140861