Skip to content

Instantly share code, notes, and snippets.

View flyakite's full-sized avatar
:bowtie:
Working from home

Shih-Wen Su flyakite

:bowtie:
Working from home
View GitHub Profile
@flyakite
flyakite / shortcutmiddleware.py
Last active August 29, 2015 13:56
Some requests require no session, auth, locale, csrf check, message, or many other middlewares. Especially, there are some useless db connection in django_session. Skip unnecessary middlewares can make the request much faster.
#
# in your settings file
#
# middleware settings
MIDDLEWARE_CLASSES = (
'some.essential.Middleware',
# this is the home-made shortcut middleware, put right above the middlewares you want to skip
'apps.middleware.ShortcutMiddleware',
@flyakite
flyakite / how_do_you_debug.xml
Created February 7, 2014 06:14
One of the request inputs is not valid. !!?? So which input and what do you mean valid?
WindowsAzureError: Unknown error (Bad Request)
<?xml version="1.0" encoding="utf-8"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>InvalidInput</code>
<message xml:lang="en-US">
One of the request inputs is not valid.
RequestId:f6fbc3c1-3494-4aec-8fce-de255b40c33c
Time:2014-02-07T06:05:40.4464752Z</message>
</error>

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
var LINE = require('./line.js');
var line = new LINE();
var email = 'your email';
var password = 'your password';
line.login(email, password, function(error, result) {
if (error) {
return;
}
@flyakite
flyakite / neo4j.sh
Created April 20, 2014 14:51
neo4j installation
# install java 1.7
# http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.tar.gz
# http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm
# http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-macosx-x64.dmg
# export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
# PATH=${PATH}:/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin
// http://jsfiddle.net/suBPQ/
$.ajax({
url: "http://api_test_server.proudlygeek.c9.io/",
success: function(data) {
console.log(data);
}
});​

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(

@flyakite
flyakite / install.sh
Last active November 15, 2015 00:29
Ionic Framework Tutorial
## Install NodeJS
## Go To https://nodejs.org/en/
## Download and Install NodeJs
## Test it!
## Open command line terminal on Mac or PowerShell on Windows
$ node -v # show node.js version
$ npm -v # show npm version
## create myapp based on sidemenu project
$ ionic start myapp sidemenu
## go to myapp folder
$ cd myapp
## list files
@flyakite
flyakite / example_usage_in_controllers.js
Last active November 30, 2015 05:46
service for $cordovaGoogleAnalytics
GA.startTrackerWithId('UA-70824422-1');
GA.trackView('News');
GA.addCustomDimension('Type', 'tips');