Skip to content

Instantly share code, notes, and snippets.

View puncoz's full-sized avatar
🇳🇵
Working from home

Puncoz Nepal puncoz

🇳🇵
Working from home
View GitHub Profile
@puncoz
puncoz / speaking_in_tongues_soln.cpp
Created April 11, 2015 09:52
A. Speaking in Tongues
/* A. Speaking in Tongues [filename: A.cpp]
Codejam :: Qualification Round 2012
---------------------------------------------
Written in C++ Programming
Tested and Compiled - Microsoft Windows 7 / Dev-C++ v4.9
*/
@puncoz
puncoz / PDO_Database.php
Created December 8, 2015 15:50
PDO database abstraction layer that you can use in your applications to allow for future flexibility in your database choice and protect you from SQL Injection.
<?php
// Define configuration
// May Include this in database configuration file
define("DB_HOST", "localhost");
define("DB_USER", "username");
define("DB_PASS", "password");
define("DB_NAME", "database");
/*
<?php
function url_encrypt($string)
{
$encrypt_method = "AES-256-CBC";
$secret_key = 'ZwZSUU50OW2doUTXNHSUNYaGZOWUwQ0c3Z2doUwQ0cNYUU3ZUT09SNHX5wZSUaG9';
$secret_iv = 'Zw0c3Z2d0OW2doUTXNoUwQ0cNYUU3ZUT09SU5HSUUwQUaG9NYaGNHX5wZSZSUZOWZw0c3Z2d5wZSZSUZOWoUwQ0cN0OWYUU3ZUT09SU5HSUUwQUaG2doUTXN9NYaGNHX';
// hash
$key = hash('sha256', $secret_key);
<?php
/**
* Class To Web-scrap nepse contents from MeroLagani Sites
*/
class Nepse
{
private $url;
private $curlResponse;
private $domDocument;
<?php
( ! defined('BASEPATH')) OR exit('No direct script access allowed');
class Excel extends CI_Controller {
public function index() {
$this->excel_to_mysql();
}
public function excel_to_mysql() {
@puncoz
puncoz / map.choropleth.nepal.R
Created April 30, 2017 13:59 — forked from anjesh/map.choropleth.nepal-updated.R
Step-by-step plotting choropleth map of Nepal
library(rgdal)
library(ggplot2)
library(dplyr)
# clone NepalMaps from https://github.com/anjesh/NepalMaps
# read shapefile
nepal.adm3.shp <- readOGR(dsn="./NepalMaps/baselayers/NPL_adm", layer="NPL_adm3", stringsAsFactors = FALSE)
# fortify shapefile data to data frame
@puncoz
puncoz / .gitlab-ci.yml
Created June 28, 2017 08:46 — forked from timilsinabishal/.gitlab-ci.yml
Gitlab CI file for continous deployment using capistrano
image: ruby:latest
before_script:
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
- ssh-add <(echo -e "$SSH_PRIVATE_KEY")
- gem install capistrano
stages:
- deploy
@puncoz
puncoz / greatest-product.php
Last active October 7, 2017 12:24
What is the greatest product of n adjacent numbers in the same direction (up, down, left, right, or diagonally) in given matrix?
<?php
/**
* 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
* 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
* 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
* 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
* 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
* 24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
* 32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
@puncoz
puncoz / gist:22f2c52a9c506ebb50dc922bfe2b72dd
Created October 29, 2017 16:36 — forked from nostah/gist:d610459d50564c729c56
php swagger 2.0 api sample
<?php
use Swagger\Annotations as SWG;
/**
* @SWG\Swagger(
* basePath="/v1",
* host="api.local",
* schemes={"http"},
* produces={"application/json"},
@puncoz
puncoz / git-commands.md
Last active February 16, 2021 02:16
Useful git commands

Useful git commands

Get local branch count

git branch | wc -l

Delete all merged branch from local

git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d