Skip to content

Instantly share code, notes, and snippets.

@simkimsia
simkimsia / stringformat.js
Created July 1, 2014 09:17
javascript function that helps convert javascript number into a nice format with the function niceFormat for thousand separator, negative uses () etc
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 / Quiz3Q4.r
Last active August 29, 2015 14:02
working for two grouped means t-test
##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 / ubuntu14.04-rails4.sh
Last active August 29, 2015 14:01
preparing a fresh 14.04 ubuntu for rails 4
#!/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 / download_composer.sh
Last active May 31, 2017 06:59
Inspired by http://askubuntu.com/a/165241/10591 this gist shows the bash commands required to have a global installation of composer and also available for all users to access
#!/bin/bash
###
#
#
# Run this by executing the following:
#
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/simkimsia/0c218cadbb3055d53417/raw/download_composer.sh)"
#
# Also, run this as root, unless you enjoy failing.
@simkimsia
simkimsia / ubuntu14.04-cake2.4.sh
Last active May 27, 2023 06:55
preparing a fresh 14.04 ubuntu for cakephp 2.4
#!/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/691e97f40b2544644f9a/raw/ubuntu14.04-cake2.4.sh)" <mysqlPassword>
@simkimsia
simkimsia / convert_query_string_to_assoc_array.js
Created April 28, 2014 13:45
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
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 ) {
<?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();
<?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();
<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 -->
@simkimsia
simkimsia / getmonitor.R
Created January 18, 2014 02:51
unable to open the 001.csv file
getmonitor <- function(id, directory, summarize = FALSE) {
path_to_directory = paste(getwd(), directory, sep="/")
temp = list.files(path=path_to_directory, pattern="*.csv")
myfiles = lapply(temp, read.delim)
print(temp)
print(myfiles)
}
print(getwd())