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
# USAGE: python rdp-disconnect.py -u kadir.malak -s 192.168.0.10 192.168.0.11 somehostname1 somehostname2 | |
from subprocess import check_output, STDOUT | |
import argparse | |
def rdp_session_id(server, username): | |
output = check_output('qwinsta /server:%s %s' % (server, username), stderr=STDOUT).decode('latin1') | |
if 'No session exists' in output: | |
return -1 | |
lines = [line.split() for line in output.split('\r\n')] |
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
package processingscala | |
import processing.core.{PApplet, PConstants} | |
object Main extends PApplet { | |
def main(args:Array[String]) = { | |
PApplet.main("processingscala.Main") | |
} | |
} |
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 unittest | |
import inspect | |
import re | |
def run_tests(clazz): | |
def is_test_method(name): | |
return re.search('^test_*', name) is not None | |
funcs = inspect.getmembers(clazz, predicate=inspect.isfunction) |
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> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
auto source = vector<string>{ | |
"#include <iostream>", |
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
(ns processing-with-clojure.core | |
(:gen-class | |
:extends processing.core.PApplet) ;; we need a class extending processing.core.PApplet | |
(:import (processing.core PConstants PApplet))) | |
(defn -main | |
[& args] | |
(PApplet/main "processing_with_clojure.core")) ;; generated class name has underscores(_) | |
;; instead of hyphens(-) |
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
(defn -draw [this] ;; override draw() method | |
(if (.-mousePressed this) | |
(.fill this 0) | |
(.fill this 255)) | |
(let [x (.-mouseX this) | |
y (.-mouseY this) | |
width 80 | |
height 80] | |
(.rect this x y width height))) ;; changed .ellipse to .rect |
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
# dummy implementation just to show the intent | |
def for1(list1, list2, list3): | |
for i in list1: | |
for j in list2: | |
for k in list3: | |
yield (i, j, k) | |
for i in for1(['a', 'b', 'c'], [1, 2], ['asd']): | |
print(i) | |
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
class Node(): | |
def __init__(self, data): | |
self.data = data | |
self.children = [] | |
def add(self, node): | |
self.children.append(node) | |
return self | |
def __str__(self): |
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 ifor(*lists): | |
root = Node('ROOT') | |
for L in lists: | |
leaves = list(root.leaves()) | |
for data in L: | |
# create once, use multiple times | |
# this way we end up with a graph, instead of a tree | |
new_node = Node(data) | |
for leaf in leaves: | |
# leaves() function may return same nodes multiple times |
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
for item in ifor(['a', 'b', 'c'], [1, 2], ['asd']): | |
print(item) | |
# outputs | |
# ['a', 1, 'asd'] | |
# ['a', 2, 'asd'] | |
# ['b', 1, 'asd'] | |
# ['b', 2, 'asd'] | |
# ['c', 1, 'asd'] | |
# ['c', 2, 'asd'] |
OlderNewer