Skip to content

Instantly share code, notes, and snippets.

View khayyamsaleem's full-sized avatar
🏠
Working from home

khayyam khayyamsaleem

🏠
Working from home
View GitHub Profile
import java.util.HashMap;
public class Pokemon {
String name, type;
int maxHP, currentHP;
HashMap<String, Integer> moves;
public Pokemon(String name, String type, int maxHP){
this.name = name;
this.type = type;
[
{
"name": "Mankey",
"type": "fighting",
"moves": [
{
"name": "low kick",
"damage": 10
},
{
[
{
"name": "Mankey",
"type": "fighting",
"moves": [
{
"name": "low kick",
"damage": 10
},
{
/* eslint-disable filenames/match-regex, import/no-commonjs */
const path = require('path');
const context = path.resolve(__dirname, 'src');
module.exports = {
context,
entry: './index.js',
module: {
rules: [
const path = require('path');
module.exports = {
entry: {
app: './src/index.js',
},
devtool: 'inline-source-map',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'index.js',
def pair_sum(my_list, target):
complements = {}
for i in range(len(my_list)):
rest = complements.get(my_list[i], None)
if rest:
return (rest[1], i)
complements[target - my_list[i]] = (my_list[i], i)
def pair_sum_slow(my_list, target):
for i in range(len(my_list)):
def pair_sum(my_list, target):
complements = {}
for i in range(len(my_list)):
rest = complements.get(my_list[i], None)
if rest:
return (rest[1], i)
complements[target - my_list[i]] = (my_list[i], i)
def pair_sum_slow(my_list, target):
for i in range(len(my_list)):
@khayyamsaleem
khayyamsaleem / red.py
Last active January 11, 2019 23:12
gets all post titles on the front page of a subreddit
import requests
from bs4 import BeautifulSoup
headers = {
'User-Agent' : 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63'
}
subreddit = input("Enter a sub-reddit name: ").strip().lower()
URL = "https://www.reddit.com/r/%s" % subreddit
const {
GraphQLObjectType,
GraphQLString,
GraphQLSchema,
GraphQLID,
GraphQLInt,
GraphQLList,
GraphQLNonNull
} = require('graphql')
counts = [ 0 for _ in range(26)]
for c in input('enter a string: '):
counts[ord(c) - 97] += 1
out = "".join([ chr(x+97) + str(y) for x,y in enumerate(counts) if y != 0])
print(out)