Skip to content

Instantly share code, notes, and snippets.

@poorcoder
poorcoder / gist:1474851
Created December 14, 2011 01:48
Bind node-validator to req
/*
* This binds the node-validator library to the req object so that
* the validation / sanitization methods can be called on parameter
* names rather than the actual strings.
*
* 1. Be sure to include `req.mixinParams()` as middleware to merge
* query string, body and named parameters into `req.params`
*
* 2. To validate parameters, use `req.check(param_name, [err_message])`
* e.g. req.check('param1').len(1, 6).isInt();
@poorcoder
poorcoder / eatenCakes.js
Last active August 29, 2015 14:07
Pete Hodgson talks about how we can expand our programming minds by using JavaScript in unusual and experimental ways in his presentation from Forward JS. http://www.youtube.com/watch?v=n9qzwI4Krmo
/*
* Pete Hodgson talks about how we can expand our programming minds by
* using JavaScript in unusual and experimental ways in his presentation
* from Forward JS.
* http://www.youtube.com/watch?v=n9qzwI4Krmo
*/
cakes = ["coffee", "cheese", "bundt", "angel"];
function Person() {
@poorcoder
poorcoder / base64.js
Created October 20, 2014 02:42
Base64 dönüşüm fonksiyonları / base64toInt - intToBase64
/*Base64 dönüşüm fonksiyonları*/
function intToBase64(i) {
var b64 = '';
b64 += String.fromCharCode((i % 64) + 63);
for (var j = 0; j < 4; j++) {
i = Math.floor(i / 64);
b64 += String.fromCharCode((i % 64) + 63);
}
return b64;
@poorcoder
poorcoder / AndroidManifest.xml
Created May 15, 2016 18:53 — forked from gabouh/AndroidManifest.xml
NativeScript Splash Screen for Android
File from app/App_Resources/Android/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
@poorcoder
poorcoder / info.plist
Created June 21, 2016 17:39 — forked from mlynch/info.plist
Disable App Transport Security in iOS 9
<!--
This disables app transport security and allows non-HTTPS requests.
Note: it is not recommended to use non-HTTPS requests for sensitive data. A better
approach is to fix the non-secure resources. However, this patch will work in a pinch.
To apply the fix in your Ionic/Cordova app, edit the file located here:
platforms/ios/MyApp/MyApp-Info.plist
And add this XML right before the end of the file inside of the last </dict> entry:
@poorcoder
poorcoder / gist:dd6e24ca36243a4bd17d95bb38f0d2c8
Created July 13, 2016 12:18 — forked from burkeholland/gist:7475bb40a305d9f35494
Customizing The Navigation Bar / Status Bar

As I've been learning more and more about NativeScript, one of the first tasks I really dove into was learning how to customize the Navigation Bar for an iOS app. NativeScript has a Navbar component on the roadmap, but for now, it requires some knowledge about the underlying iOS implementation of UINavigationControllers, UIViewControllers and the like.  But fear not!  I have braved the treacherous waters of StackOverflow and the Objective-C docs and emerged, victorious and unscathed.

1

In this article, I’ll go over a few of the more common tweaks that you might be needing to make to the Navigation Bar or Status Bar. While NativeScript is a cross-platform framework, these tweaks apply specifically to iOS. However, most of the items that I will

@poorcoder
poorcoder / nginx.conf
Created September 13, 2016 05:33 — forked from fideloper/nginx.conf
Nginx redirects
server {
# ...
# Redirect /book and any sub-uris
# e.g. /book/anything
# e.v. /book/whatever?maybe=a_query_too
location /book {
return 301 http://book.serversforhackers.com;
}
@poorcoder
poorcoder / gist:9b16b189cc157c182c7d9c4348ed1993
Created September 13, 2016 05:33 — forked from fideloper/gist:0dfb4491ffefba6766eb
nginx cache secondary php location
fastcgi_cache_path /tmp/cache levels=1:2 keys_zone=images:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
#root /usr/share/nginx/html;
root /var/www/html;
index index.html index.htm;
server {
# Redirect any subdomain to the root domain
# to be captured by next server block
server_name *.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
root /var/www;
index index.html index.htm;
@poorcoder
poorcoder / ngxhost.sh
Created September 13, 2016 05:34 — forked from fideloper/ngxhost.sh
Vhost creation file for nginx
#!/usr/bin/env bash
if [ $EUID -ne 0 ]; then
echo "You must be root: \"sudo ngxvhost\""
exit 1
fi
# May need to run this as sudo!
# I have it in /usr/local/bin and run command 'ngxvhost' from anywhere, using sudo.