Skip to content

Instantly share code, notes, and snippets.

View androidmanifest_main_activity.xml
<activity android:name="MainActivity">
<!-- This activity is the main entry, should appear in app launcher -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ShareActivity">
<!-- This activity handles "SEND" actions with text data -->
View AppErrorHandler.php
<?php
App::uses('AppException', 'Lib');
App::uses('ErrorHandler', 'Error');
class AppErrorHandler extends ErrorHandler {
public static function handleException(Exception $exception) {
if ($exception instanceof AppException) {
$element = 'default';
$message = $exception->getMessage();
View AppErrorHandler.php
<?php
App::uses('AppException', 'Lib/Exception');
App::uses('ErrorHandler', 'Error');
class AppErrorHandler extends ErrorHandler {
public static function handleException(Exception $exception) {
if ($exception instanceof AppException) {
$element = 'default';
$message = $exception->getMessage();
@simkimsia
simkimsia / convert_query_string_to_assoc_array.js
Created Apr 28, 2014
able to convert query string like ?q=abc&g[]=1&g[]=2 into a javascript object (params) which has 2 params q & g. The params.q will be 'abc' string while params.g will be an array containing the value 1, 2
View convert_query_string_to_assoc_array.js
RegExp.quote = function(str) {
return (str+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
}
function getSearchParameters() {
var prmstr = window.location.search.substr(1);
return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
}
function transformToAssocArray( prmstr ) {
@simkimsia
simkimsia / ubuntu14.04-rails4.sh
Last active Aug 29, 2015
preparing a fresh 14.04 ubuntu for rails 4
View ubuntu14.04-rails4.sh
#!/bin/bash
###
#
# forked from https://gist.github.com/1264701/08f93534ba177f173b9382b53c419cd0de5b07ea
#
# Ubuntu 14.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 14.04 server:
#
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/simkimsia/0fe0a5eb9c7504ead53c/raw/58438c9a7c132be94fe5d6687b6f9623968b927f/ubuntu14.04-rails4.sh)" <mysqlPassword>
@simkimsia
simkimsia / Quiz3Q4.r
Last active Aug 29, 2015
working for two grouped means t-test
View Quiz3Q4.r
##Q4
## Refer to the setting of the previous question.
## To further test the system,
## administrators selected 20 nights and
## randomly assigned the new triage system to be used on
## 10 nights and the standard system on the remaining 10 nights.
## They calculated the nightly median waiting time (MWT) to see
## a physician. The average MWT for the new system was
## 3 hours with a variance of 0.60 while
## the average MWT for the
@simkimsia
simkimsia / stringformat.js
Created Jul 1, 2014
javascript function that helps convert javascript number into a nice format with the function niceFormat for thousand separator, negative uses () etc
View stringformat.js
if (!Number.prototype.niceFormat) {
Number.prototype.niceFormat = function(options) {
var defaultOptions = {
thousandSeparator: ',',
leftPad: 0,
decimalPlaces: 2,
negative: '()'
};
var env = defaultOptions;
if (typeof options != 'undefined') {
@simkimsia
simkimsia / explanation.txt
Last active Aug 29, 2015
what is properly namespaced JSON response?
View explanation.txt
1. I thought namespaced means you need to have the name of the record as the key.
2. If I misunderstood, please feel free to correct me.
3. When you say namespace, do you mean that the namespace is the "data" key?
@simkimsia
simkimsia / install-cake3-ubuntu-14-04.sh
Last active Aug 29, 2015
preparing fresh 14.04 ubuntu install for cake 3
View install-cake3-ubuntu-14-04.sh
#!/bin/bash
###
#
# forked from https://gist.github.com/1264701/08f93534ba177f173b9382b53c419cd0de5b07ea
#
# Ubuntu 14.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 14.04 server:
#
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/simkimsia/4a3808cd109dbd1a3913/raw/d0a9799cdbf0857043b7b59a489361388c09fc4a/install-cake3-ubuntu-14-04.sh)" <mysqlPassword>
@simkimsia
simkimsia / OAuth2SecurityConfiguration.java
Created Oct 26, 2014
code sample for OAuth2SecurityConfiguration
View OAuth2SecurityConfiguration.java
@Configuration
public class OAuth2SecurityConfiguration {
// This first section of the configuration just makes sure that Spring Security picks
// up the UserDetailsService that we create below.
@Configuration
@EnableWebSecurity
protected static class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired