Skip to content

Instantly share code, notes, and snippets.

sheet_main <- read_excel(kobo.data.filename, sheet=1)
sheet_main <- data.frame(lapply(sheet_main, trimws))
sheet_main["basic_info_household.a6"] <- choices[match(sheet_main[["basic_info_household.a6"]], choices$name),3]
sheet_main["basic_info_household.a7"] <- choices[match(sheet_main[["basic_info_household.a7"]], choices$name),3]
sheet_main["a6_01"] <- choices[match(sheet_main[["a6_01"]], choices$name),3]
WriteXLS(x=c("sheet_main"), "sheet_main.xls")
@anjesh
anjesh / php-source-exploration-process.md
Created August 14, 2017 14:21
Notes taken during php source exploration to identify weird error message
@anjesh
anjesh / map.choropleth.nepal-updated.R
Last active January 8, 2021 12:28
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_shp <- readOGR(dsn="NepalMaps/baselayers/NPL_adm", layer="NPL_adm3", stringsAsFactors = FALSE)
# fortify shapefile data to data frame
shp_df <- fortify(nepal_shp, region = "NAME_3")
@anjesh
anjesh / nsic-pdf-scraper.R
Last active March 27, 2017 17:19
The R code to scrape NSIC data and code from PDF (for Nepal Standard Industrial Classification)
library(tm)
# download pdf from http://cbs.gov.np/image/data/Publication/Others/Nepal%20Standard%20Industrial%20Classification.pdf
# using tricks from http://stackoverflow.com/questions/3852354/extracting-text-data-from-pdf-files
nsic.pdf.file <- "data/nsic/Nepal Standard Industrial Classification.pdf"
Rpdf <- readPDF(control = list(text = "-layout"))
nsic.pdf.corpus <- VCorpus(URISource(nsic.pdf.file), readerControl = list(reader = Rpdf))
nsic.pdf.lines <- content(content(nsic.pdf.corpus)[[1]])
@anjesh
anjesh / test.xml
Created January 9, 2017 11:46
IATI XML for testing
<?xml version="1.0" encoding="UTF-8"?>
<iati-activities generated-datetime="2016-02-22T11:04:07+00:00" version="2.02">
<!-- Generated By AidStream -->
<iati-activity xml:lang="en" default-currency="GBP" last-updated-datetime="2016-02-22T11:01:34+00:00" hierarchy="1">
<iati-identifier>KE-TEST-9381-P100</iati-identifier>
<reporting-org ref="KE-NGC-9381" type="21"/>
<title>
<narrative>Test Activity</narrative>
</title>
<description type="1">
@anjesh
anjesh / charset.sh
Created November 2, 2016 07:14
charset encoding and converting using bash
#find the charset
file -I filename
#convert the given encoding to itf-8
iconv -f $(file -bI filename | sed -e "s/.*[ ]charset=//") -t utf-8 filename
@anjesh
anjesh / tunisia.api.package.json
Last active July 11, 2016 05:38
Tunisia CKAN API Package info
{
"packages": [
{
"license_title": "Open Tunisian License (OTL) compatible with data.industrie.gov.tn",
"maintainer": "Sdiri Mohamed",
"relationships_as_object": [],
"private": false,
"maintainer_email": "",
"revision_timestamp": "2016-06-14T12:53:22.211153",
"id": "e868cc9e-cdd9-470f-9de3-fa906834382f",
@anjesh
anjesh / 0_reuse_code.js
Created May 31, 2016 10:49
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
@anjesh
anjesh / map_to_ocds.js
Last active June 8, 2016 11:29
This joins the 3 collections (tenders, contracts, tender_items) into one single collection (release)
/*
To run this script, run the following command in the cli
# mongo localhost:27017/[dbname] map_to_ocds.js
*/
//remove ocds_release collection
db.ocds_release.remove({})
// var bulk = db.ocds_release.initializeUnorderedBulkOp();
@anjesh
anjesh / contract-89270.json
Last active December 25, 2015 11:58
Tender with 2 contracts for tender.id = 25610 and regNumber = 12/00001
{
"tender": {
"regNumber": "12/00001",
"stateOrg": {
"treasutyAcc": null,
"bankAccount": null,
"fax": "268 22692 078883935",
"code": "1009601000289",
"fkRefTerDepTreasure": null,
"orgName": "Agenția de Dezvoltare Regională Centru",