Skip to content

Instantly share code, notes, and snippets.

View arnabkd's full-sized avatar

Arnab Datta arnabkd

View GitHub Profile
public static void main () {
System.err.println();
}
[{
"cells": {"1": "one", "2": "two"}
}]
@arnabkd
arnabkd / math_quiz.py
Created June 12, 2012 11:15
Example of FP and imperative in python
#Task 9.5 - Arnab Kumar Datta (arnabkd)
import operator,random
levels = {'B' : 10 , 'I': 25 , 'A':100}
func = {'add': operator.add, 'mul' : operator.mul, 'sub' : operator.sub}
ops = {func['add'] : '+' , func['mul'] : '*', func['sub'] : '-'}
messages = ['Please ask your math teacher for help!','You need more practice.',\
'Well done!']
def play(level,op):
operand1 = random.randint(1,level); operand2 = random.randint(1,level)
import random
def rand7():
return random.randrange(1,8)
def rand5_mod():
return rand7() % 5 + 1
def rand5_recursive():
roll = rand7()
irb(main):001:0> require 'capybara/culerity'
=> true
irb(main):002:0> session = Capybara::Session.new(:culerity)
=> #<Capybara::Session>
irb(main):003:0> session.visit('http://www.vg.no')
Capybara::DriverNotFoundError: no driver called :culerity was found, available drivers: :rack_test, :selenium
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.5.0/lib/capybara/session.rb:82:in `driver'
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.5.0/lib/capybara/session.rb:232:in `visit'
from (irb):3
from /usr/bin/irb:12:in `<main>'
require 'terminal-table/import'
class SubsetSumMatrix
class << self
def create_empty_for(array)
matrix = []
header = [nil] + build_header_from(array)
matrix << header
array.each_with_index do |element,i|
row = header.collect{|value| 'F'}
#return fitness of a path
def fitness(path):
pass
#swap two random indices
def random_swap(l):
i = randint(0,len(l) - 1)
j = randint(0,len(l) - 1)
l[i], l[j] = l[j], l[i]
return l
const express = require('express')
const graphqlHTTP = require('express-graphql')
import schema from './schema'
// The root provides a resolver function for each API endpoint
const root = {
hello: () => 'World'
}
const app = express()
@arnabkd
arnabkd / seed.graphql
Created August 20, 2018 09:28
Solved by using aliases and unique key (email)
mutation{
speaker: createSpeaker(data: {
name: "Name"
email: "example@example.com"
workplace_url: "some_workplace_url"
}){
id
}
talkOne: createTalk(data: {
import React from 'react'
import { PropTypes } from 'prop-types'
import { Query } from 'react-apollo'
import gql from 'graphql-tag'
const Speaker = ({match}) => {
Speaker.Proptypes = {
match: PropTypes.shape({
params: PropTypes.shape({
id: PropTypes.String