This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I have written a small snippet to open a given url which doest open on first time and i need to | |
#Keep refreshing it. | |
import webbroswer | |
import time | |
url = "the url u want to enter" | |
for i in range(5): | |
webbrowser.open_new_tab(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main() | |
{ | |
int a,b,c=0; | |
cin >> a >> b; | |
while(a) | |
{ | |
if(a&1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def LetterCountI(str): | |
l = [] | |
index = 0 | |
for k,i in enumerate(str.split(' ')): | |
d = {} | |
for j,c in enumerate(i): | |
d[c] = d.get(c,0) + 1 | |
d = {key: value for key, value in d.items() if value != 1} | |
if (not l): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To get a dictionary of repeated characters in a given string | |
some_dict = {} | |
for i,c in enumerate("testing"): | |
some_dict[c] = some_dict.get(c,0) + 1 | |
some_dict = {key: value for key, value in some_dict.items() if value != 1} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open('data.txt' ,'r') | |
import re | |
d = {} | |
title = "" | |
for i in f: | |
j = i.split("\n") | |
if j[0] != '#' and j[0] != '': | |
if re.match('#',j[0]): | |
title = j[0] | |
title_info = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
from __future__ import division | |
import operator | |
class Slack: | |
def __init__(self): | |
self.items = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import sys | |
def splitstr(n,cut_list): | |
if len(cut_list) == 0: | |
return [0,[]] | |
min_positions = [] | |
min_cost = sys.maxint | |
for k in cut_list: | |
left_split = [ x for x in cut_list if x < k] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-i586.tar.gz | |
wget http://apache.mirrors.pair.com//cassandra/2.0.7/apache-cassandra-2.0.7-bin.tar.gz | |
tar -xvf jdk-7u55-linux-i586.tar.gz\?AuthParam\=1397971823_52e8ace10923c9f8a5705faca17b4719 | |
gunzip apache-cassandra-2.0.7-bin.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineFactory; | |
import javax.script.ScriptEngineManager; | |
import org.luaj.vm2.*; | |
import org.luaj.vm2.lib.jse.*; | |
import javax.script.CompiledScript; | |
import javax.script.Bindings; | |
import javax.script.Compilable; | |
public class ScriptEngineSample { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
divmod() function is a handy tool in such cases. | |
>>> divmod(10,2) | |
(5, 0) | |
''' | |
r = set() | |
def factorize(n): | |
for i in range(1,int(n ** 0.5) + 1 ): | |
div,mod = divmod(n,i) | |
if mod == 0: |
NewerOlder