Skip to content

Instantly share code, notes, and snippets.

function sum(ary) {
var result = 0;
for (var i = 0; i < ary.length; i++) {
result += ary[i];
}
return result;
}
iteration = 0
count = 0
while iteration < 5:
for letter in "hello, world":
count += 1
print("Iteration " + str(iteration) + "; count is: " + str(count))
iteration += 1
@trakhov
trakhov / wallp_api.rb
Last active September 12, 2016 18:04
This ruby script downloads a random photo from flickr.com (search by "1680x1050" and "nature" tags).
require 'flickraw'
require 'open-uri'
FlickRaw.api_key="your api key"
FlickRaw.shared_secret="your secret"
args = {
tags: "1680x1050,nature",
tag_mode: "all",
per_page: 500,
#!/bin/bash
# Copyright (c) 2011 Josh Schreuder
# http://www.postteenageliving.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
function sopcast_vlc () {
Downloads/sp-auth/sp-sc-auth \
sop://broker.sopcast.com:3912/"$1" 3908 8908 > /dev/null &
sleep 5;
vlc http://localhost:8908/tv.asf;
killall sp-sc-auth;
}
>>> $A # у нас есть точка
<A = (1.64, 2.16)>
>>> $B # еще одна
<B = (4.16, 1.96)>
>>> List = [$A] # поместим одну из них в список
>>> List # проверим, там ли она:
[<A = (1.64, 2.16)>]
>>> $A in List
True # True, то есть, да
@trakhov
trakhov / some.py
Last active December 16, 2015 23:29
def print_strategy(P, name):
s = '$ {} = \left('.format(name)
for el in P:
if el.denominator > 1:
s += '\\frac{{ {} }}{{ {} }}, '.format(el.numerator, el.denominator)
else:
s += '{}, '.format(el)
s = s.rstrip(', ')
s += '\\right)$'
return s