Skip to content

Instantly share code, notes, and snippets.

@simkimsia
simkimsia / installGuestAdditions.sh
Last active December 18, 2015 04:39
commands to reinstall Guest Additions You need to place the .iso file via VirtualBox GUI
#!/bin/bash
###
#
# Copyright (c) 2013 KimSia Sim
#
# Ubuntu 13.04 vm to reinstall the Guest Additions
#
# partly inspired by https://github.com/fespinoza/checklist_and_guides/wiki/Creating-a-vagrant-base-box-for-ubuntu-12.04-32bit-server
#
<VirtualHost test.localhost:80>
DocumentRoot "C:/Users/yada/Documents/GitHub/testapp/src/testapp/webroot"
ServerName test.localhost
ErrorLog "logs/testapp.local-error.log"
CustomLog "logs/testapp.local-access.log" combined
<Directory "C:/Users/yada/Documents/GitHub/testapp">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
@simkimsia
simkimsia / PuzzleSolved.java
Last active December 20, 2015 06:58
puzzle solved for some silly programming problems in academic school
import java.util.*;
import java.lang.*;
public class PuzzleSolved {
public static void main (String[] args) {
int m = 4; // m is the number of sub puzzles OR number of digits, e.g. 4
int k = 2; // k is the puzzle difficulty OR bit space per digit, e.g. 2
int maxDigitSize = (int) Math.pow(2, k) - 1; // e.g. we expect this to be 3
int x = maxDigitSize + 1; // x represents the x-nary space we are in. binary means x is 2.
@simkimsia
simkimsia / setup-nginx-conf.sh
Last active December 20, 2015 08:39
Setup the initial nginx conf file for the very first time. Will point to stage.WEBAPP first
#!/bin/bash
###
#
# Copyright (c) 2013 KimSia Sim
#
# Ubuntu 12.10 based make nginx config files in /etc/nginx/sites-available and /etc/nginx/sites-enabled for
# webapp.com built using cakephp
# Run this by executing the following from a fresh install of Ubuntu 12.10 server:
#
[2013-08-11 16:53:52] ConvertEPub.INFO: Sleeping 10 seconds. [] []
[2013-08-11 16:54:03] ConvertEPub.ERROR: No job found. [] []
[2013-08-11 16:54:03] ConvertEPub.NOTICE: No Job found. [] []
[2013-08-11 16:54:03] ConvertEPub.INFO: Sleeping 10 seconds. [] []
[2013-08-11 16:54:13] ConvertEPub.INFO: Running chained new job () with workers ["DownloadS3Files"] []
[2013-08-11 16:54:13] ConvertEPub.INFO: Running new job (1) with worker: DownloadS3Files [] []
<script type="text/html" id="resultItemTemplate">
<% _.each(Site, function (site) { %>
<a href="#"><%= site.name %></a>
<% }); %>
</script>
@simkimsia
simkimsia / EditView.php
Created August 18, 2013 04:02
This is how we make the form input fields in CakePHP more like Excel Currency Format cells http://stackoverflow.com/a/1162744/80353
<div class="voucherCategories container_16">
<div class="grid_16" style="text-align: center" >
<?php echo $this->element('products_link_bar'); ?>
<h2><?php echo __('Edit ' . $this->Form->value('VoucherCategory.name')); ?></h2>
</div>
<?php echo $this->Form->create('VoucherCategory'); ?>
<fieldset class="grid_16">
<?php
echo $this->Form->input('id');
@simkimsia
simkimsia / DoSomethingEmail.php
Last active December 24, 2015 11:19
send email using cake templates
public function successfulSomething($data) {
$email = $this->email;
$email->subject('You have successfully done something:' . $data['title']);
$email->template('successful_done');
$email->sendAs = 'text';
$email->viewVars($data);
if (EMAIL_ON) {
$result = $email->send();
} else {
$result = $email;
@simkimsia
simkimsia / infinite.html
Created October 24, 2013 10:59
how to use $index in ng-repeat
<div ng-repeat='item in my_works.items'>
<!-- if index mod 3 == 0 show <div>-->
<!-- if index mod 3 == 2 show </div>-->
</div>
@simkimsia
simkimsia / fetch_works_app.js
Created October 29, 2013 12:52
How I use nginfinite scroll to fetch works
var fetchMyWorks = angular.module('fetchMyWorks', ['infinite-scroll']);
var bookContainerHeight = 341;
var bookContainerWidth = 180;
var gapBetweenEachColumn = 13;
var gapBetweenEachRow = 13;
var initial = 46; // height from top
var defaultHeight = 662;
fetchMyWorks.controller('StoriesController', function($scope, MyWorks) {