Skip to content

Instantly share code, notes, and snippets.

View bistaumanga's full-sized avatar

bistaumanga bistaumanga

View GitHub Profile
@bistaumanga
bistaumanga / media_outlets_bias_mbfc_oct2020.csv
Last active November 8, 2022 23:43
Media outlets bias and factuality from MBFC (oct 2020)
title country mbfc_page bias_raw Factual Ideology url
Alliance for Justice (AFJ) USA left left8 High L https://www.afj.org/
Act.TV USA left left4 MostlyFactual L http://act.tv
ACHNews USA left left8 MostlyFactual L https://achnews.org/
AlterNet USA left left2 Mixed L https://www.alternet.org/
Al DIA USA left left4 Mixed L https://aldianews.com
Aftonbladet Sweden left left9 Mixed L https://www.aftonbladet.se
Alt News India left left10 High L https://www.altnews.in
Amandla South Africa left left7 High L http://aidc.org.za/amandla-media/
ANX Media (American News X) USA left left3 Mixed L http://anx.media/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bistaumanga
bistaumanga / Monoid.scala
Created July 30, 2016 15:28
simulacrum + machinist
import simulacrum.{op, typeclass}
import scala.language.experimental.macros
object MyOps extends machinist.Ops{
override def operatorNames: Map[String, String] = Map(
"$bar$plus$bar" -> "plus"
)
}
@bistaumanga
bistaumanga / loan.scala
Last active February 6, 2016 15:45
pwlktm02
val rawData = sc.textFile("hdfs://hdfs-nn-host.com:9000/user/umb/bank/bank.csv")
rawData.take(5)
// 30;"unemployed";"married";"primary";"no";1787;"no";"no";"cellular";19;"oct";79;1;-1;0;"unknown";"no"
implicit def str2int(x: String) = x.toInt // because i'm lazy
// case class for representing data row
case class DataRow(age: Int,
job: String,
maritial: String,
@bistaumanga
bistaumanga / changed.csv
Created August 25, 2014 10:29
Students whose entrance scores changed
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 10.
"","ROLLNO","FORMNO.x","NAME.x","GENDER.x","SCORE.x","RANK.x","FORMNO.y","NAME.y","GENDER.y","SCORE.y","RANK.y","diff_percentage"
"1",6894,"2071-2878","SURENDRA KUNWAR","Male",73.68,499,"2071-2878","SURENDRA KUNWAR","Male",48.223,4294,25.457
"2",7114,"2071-11158","TEZINA KHADKA","Female",66.62,1183,"2071-11158","TEZINA KHADKA","Female",50.076,3919,16.544
"3",7126,"2071-5200","TILAK PRASAD BHATT","Male",65.69,1289,"2071-5200","TILAK PRASAD BHATT","Male",41.51,5766,24.18
"4",7124,"2071-10055","TILAK GIRI","Male",62.32,1713,"2071-10055","TILAK GIRI","Male",72.5,613,-10.18
"5",6895,"2071-317","SURENDRA NEPAL","Male",61.95,1768,"2071-317","SURENDRA NEPAL","Male",87.409,13,-25.459
"6",7122,"2071-7648","TIKAM RAI","Male",59.67,2111,"2071-7648","TIKAM RAI","Male",40.58,5947,19.09
"7",7115,"2071-5978","THAKUR LAMICHHANE","Male",54.93,2936,"2071-5978","THAKUR LAMICHHANE","Male",70.199,801,-15.269
"8",63,"2071-5163","AASHISH CHANDRA","Male",53.31,3237,"2071-5163","AASHISH CHANDRA","Male",45.671,4874,7.639
"9",7113,"2071
@bistaumanga
bistaumanga / ioe.R
Last active August 29, 2015 14:05
Ioe revised entrance analysis
ioe1 <- read.csv('/Volumes/umb/ioe entrance/ioe-first.csv')
ioe1 <- subset(ioe1, select = c(1:6))
ioe2 <- read.csv('/Volumes/umb/ioe entrance/ioe second.csv')
require('dplyr')
ioe_joined = inner_join(ioe1, ioe2, by = "ROLLNO")
ioe_joined$diff_percentage <- ioe_joined$SCORE.x - ioe_joined$SCORE.y
ioe_contrasts <- filter(ioe_joined, diff_percentage > 0.1 | diff_percentage < -0.1)
write.csv(ioe_contrasts, "~/changed.csv")
@bistaumanga
bistaumanga / iris.ipynb
Created July 27, 2014 07:12
iris data analysis and logistic regression
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bistaumanga
bistaumanga / DisjointSet.scala
Last active August 29, 2015 14:03
Union Find data structures implemented as Lazy Unions with optimizations(Union By Rank and Path Compressions)
package util
import scala.collection.mutable.HashMap
import scala.collection.mutable.ArrayBuffer
class DisjointSet[Element] {
private val parent = new HashMap[Element, Element]
private val rank = new HashMap[Element, Int]
@bistaumanga
bistaumanga / BinaryHeap.scala
Last active May 20, 2022 04:20
Binary Heap implementation in Scala. It can be used for priority queue. In addition to standard Priority Queue available in Java or Scala, this supports delete and update on K-V pair(Priority is defined by Value) with addition pointer/map stored to the keys.
package util
import scala.collection.mutable.HashMap
import scala.collection.mutable.ArrayBuffer
/*
* Single Array Based Binary Min Heap
*/
class BinaryHeap[T]{
@bistaumanga
bistaumanga / dtw_pattern.py
Created March 11, 2014 11:14
Alignment of tokens in 2 sentence to generate pattern using Dynamic time warp.
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 11 11:05:05 2014
@author: logpoint
"""
import numpy as np