Skip to content

Instantly share code, notes, and snippets.

View kingkarki's full-sized avatar

Krishna Karki kingkarki

View GitHub Profile
@kingkarki
kingkarki / gist:1e433d9a0305ed505da5
Created November 18, 2014 08:17
Perfect Php ICS Generator
<?php
// Variables used in this script:
// $summary - text title of the event
// $datestart - the starting date (in seconds since unix epoch)
// $dateend - the ending date (in seconds since unix epoch)
// $address - the event's address
// $uri - the URL of the event (add http://)
// $description - text description of the event
// $filename - the name of this file for saving (e.g. my-event-name.ics)
//
@kingkarki
kingkarki / binpacking.php
Created December 23, 2013 04:45
Suppose i have to divide all 7 bags in 4 container equally by balancing there weight. But i cannot break the bag to manage weight. Here is the function which will do it.
<?php
$bags = array(60,80,20,10,80,100,90,20,89,830,88);
$containers = array(1=>10000,2=>10000,3=>10000,4=>10000); // number -> free space
$placement = array();
function bestContainerFor($weight) {
global $containers;
$rest = 0;
$out = 0; // in it won't change $weight fits nowhere
@kingkarki
kingkarki / debug_helper.php
Last active December 30, 2015 18:39
Simple Codeigniter debug function like cake php
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (!function_exists('debug')) {
function debug($data) {
$dub = debug_backtrace();