Skip to content

Instantly share code, notes, and snippets.

View hay-wire's full-sized avatar

Prashant Kumar hay-wire

View GitHub Profile
@hay-wire
hay-wire / number_to_words_indian_format.php
Created January 26, 2016 16:15
A PHP function to convert numbers to words. Useful for currency displays, etc.
<?php
// Adapted from a buggy script original written by vgurudev at nikshepa dot com
// You can find the original script at: http://php.net/manual/en/function.number-format.php
function convertNumberToWordsForIndia($number){
//A function to convert numbers into Indian readable words with Cores, Lakhs and Thousands.
$words = array(
'0'=> '' ,'1'=> 'one' ,'2'=> 'two' ,'3' => 'three','4' => 'four','5' => 'five',
'6' => 'six','7' => 'seven','8' => 'eight','9' => 'nine','10' => 'ten',
'11' => 'eleven','12' => 'twelve','13' => 'thirteen','14' => 'fouteen','15' => 'fifteen',
@hay-wire
hay-wire / 0_reuse_code.js
Created January 26, 2016 16:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hay-wire
hay-wire / Userlocation.js
Created July 18, 2016 20:15
Browser based Javascript to get user's location using html5 geolocation API and reverse geocoding service of Google Maps.
var getAddr = function(lat, lng) {
console.log("getting addr ");
var latlng = new google.maps.LatLng(lat, lng);
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({
'latLng': latlng
}, function(results, status) {
console.log("geocode result: ", results, " and status: ", status);
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
@hay-wire
hay-wire / git-command
Created August 14, 2018 01:51
Git commit deleted files - when you have deleted a lot of unwanted files
# Taken from this blog - http://tylerfrankenstein.com/code/how-git-rm-all-deleted-files-shown-git-status
git commit `git status | grep deleted | awk '{print $2}'` -m "removed unwanted files"
@hay-wire
hay-wire / gist:8f328894a1fad2abacfe93fac0bca0c5
Created October 3, 2018 17:44
File uploading with multer and express
const express = require('express');
const router = express.Router();
const multer = require('multer');
const path = require('path');
const debug = require('debug')('myNameSpace');
const ALLOWED_IMAGE_TYPES = ['png', 'jpg', 'gif'];
const publicFilesDestination = path.join('public', 'static', 'uploads', '/');
let fileStorage = multer.diskStorage({