Skip to content

Instantly share code, notes, and snippets.

View nootanghimire's full-sized avatar
🌱

Nootan Ghimire nootanghimire

🌱
View GitHub Profile
@nootanghimire
nootanghimire / repsportal.js
Last active August 29, 2015 13:56
open data day script
alert('Hello');
console.writeline("Started");
var mainUrl = "https://reps.mozilla.org/api/v1/rep/?offset=0&limit=0"; //Thanks to Debeloper
var Ajax = new XMLHttpRequest();
Ajax.onreadystatechange = function(){
if(Ajax.status == 200 && Ajax.readyState == 4){
//Found the data. Now do the function.
var rep_rep_JSON = JSON.parse(Ajax.responseText);
themain(rep_rep_JSON);
}
@nootanghimire
nootanghimire / a.stopwatch.basic.cpp
Last active November 8, 2019 21:29
Basic Stopwatch in C++ using ctime (or time.h)
/************************************************************************
* @author Nootan Ghimire <[email protected]>
* @file a.stopwatch.basic.cpp
* @includes conioLinux.h (Modified the code from StackOverflow)
*
* @license Creative Commons: Attribution-ShareAlike 4.0 International
(CC BY-SA 4.0)
* @license http://creativecommons.org/licenses/by-sa/4.0/deed.en_US
*
* @desc A Simple Stopwatch.
@nootanghimire
nootanghimire / postfix-eval-new.cpp
Last active May 29, 2018 05:11
Stack/Queue Implementation in C++ and Application in Expression Evaluations
/******************************************************
* @author Nootan Ghimire <[email protected]>
* @file postfix-eval.cpp
* @desc Evaluation of Multi-Digit Postfix Expression
*****************************************************/
// C++ Includes
#include <iostream>
#include <cctype>
#include <cstdlib>
@nootanghimire
nootanghimire / trimfn.cpp
Last active December 31, 2015 04:09
Trim in C++
#include<iostream>
#include<cstring>
char* trim(char* str);
int main(){
return 1;
}
char* trim(char* str){
@nootanghimire
nootanghimire / convert.php
Created November 7, 2013 06:45
Converts numbers into nepali
<?php
function convert($num){
$arr = array(०,१,२,३,४,५,६,७,८,९);
$newArr = array();
$sep = str_split($num); //implicit string conversion
foreach($sep as $key=>$value){
$newArr[$key] = $arr[$value];
}
return implode('',$newArr);
@nootanghimire
nootanghimire / l10n-helper.js
Last active December 26, 2015 20:19
A localization mapping logic. Check http://jsfiddle.net/V92cK/5/ for a demo.
var Obj = '{"my":"मेरो","name": "नााम","is-xyz": "xyz-हो",".":"।","1":"१","2":"२","3":"३","4":"४","5":"५","6":"६","7":"७","8":"८","9":"९","0":"०"}';
//^^ The Localisation Objecy (Read from file or any other source)
ObjReal = JSON.parse(Obj); //Parsing the JSON
//The function starts
var l10n = function(localeObject, content){
var arr = content.split(" ").reverse(); //Split by space. and reverse (actually non-reversed) the order
@nootanghimire
nootanghimire / gist:6527881
Last active December 22, 2015 20:39
Get upto second child!
<?php
$q = "SELECT * FROM table WEHRE parent=0" ;
$res = mysql_query($q);
while ($row = mysql_fetch_array($res)){
$q1 = "SELECT * FROM table WHERE parent = ". $row['id'];
$res1 = mysql_query($q1);
while($row1 = mysql_fetch_array($res1){
$q2 = "SELECT * FROM table WHERE parent = ". $row1['id'];
$res2 = mysql_query($q2);
while($row2 = mysql_fetch_array($res2)){
#ducky.py -- returns the first website searched by
#duckduckgo
#[email protected]
import webbrowser
import sys
#print (sys.argv)
lst = sys.argv
@nootanghimire
nootanghimire / gist_content1
Last active December 20, 2015 06:48 — forked from rhoit/tkinter py2→py3
tkinter py2 → py3
py2 → py3
Tkinter → tkinter
tkMessageBox → tkinter.messagebox
tkColorChooser → tkinter.colorchooser
tkFileDialog → tkinter.filedialog
tkCommonDialog → tkinter.commondialog
tkSimpleDialog → tkinter.simpledialog
tkFont → tkinter.font
Tkdnd → tkinter.dnd
ScrolledText → tkinter.scrolledtext
@nootanghimire
nootanghimire / webapp.js
Last active December 17, 2015 21:59
Trying to ue devisestorage api
(function () {
var pickAnything = document.querySelector("#pick-anything");
if (pickAnything) {
pickAnything.onclick = function() {
var storage = navigator.getDeviceStorage("sdcard");
cursor = storage.enumerate();
cursor.onerror = function() {