Skip to content

Instantly share code, notes, and snippets.

View kiriappeee's full-sized avatar

Adnan Issadeen kiriappeee

View GitHub Profile
@kiriappeee
kiriappeee / Program.cs
Created November 26, 2011 16:02
Emulating 'LIKE' operator using Linq with arrays
/**
* If you search the internet I haven't seen much of a solution for people being able to emulate
* the LIKE operator in C# using LINQ with arrays. Most of the solutions run along the lines of working
* with the contains() method.
* But the LIKE operator is essentially somewhat of a dumbed down version of regex.
* In this example I have several class names and I wanted to know which classes match a particular
* pattern; the pattern I wanted to match was all classes ending with 'det'
* And given below is the working example of this as a console application.
**/
using System;
@kiriappeee
kiriappeee / gist:3031597
Created July 2, 2012 07:05
Making a kinect recognize the single player skeleton only
/*Having made a kinect game as promotions for our company, we discovered that there was a problem in taking this game out into
public and that was that if anyone stood behind the main player the game would just break in the sense
it wouldn't know how to track*/
//the code given by microsoft to activate the kinect tracking is as follows.
playerSkeleton = (from s in skeletonData
where s.TrackingState == SkeletonTrackingState.Tracked
select s).FirstOrDefault();
@kiriappeee
kiriappeee / gist:3223900
Created August 1, 2012 05:16
Adding base styles to controls in XAML
<window.resources>
<style targettype="{x:Type ContentControl}" x:key="BaseContentControlStyle">
<setter Property="Foreground" Value="#FF204E93" />
<style basedon="{StaticResource BaseContentControlStyle}" targettype="{x:Type Label}">
<setter Property="FontSize" Value="9.2pt" />
<style basedon="{StaticResource BaseContentControlStyle}" targettype="{x:Type Button}">
@kiriappeee
kiriappeee / gist:3223910
Created August 1, 2012 05:19
Adding a style to an entire element within a XAML Tree
<grid textelement.fontfamily="Lucida Grande" x:name="LayoutRoot">
<!-- All other controls in here will automatically inherit Lucida Grande as their font unless specified explicitly not to do so -->
</grid>
@kiriappeee
kiriappeee / monty.py
Created December 17, 2012 09:03
Testing the Monty Hall Problem
"""As much as I understood the theorems of the monty hall problem
my brain simply refused to take it in and accept, so I wrote a very quick (and dirty) script to just test it out.
The script randomly generates two goats (designated as 0) and a car (designated by 1) for three doors (stored in a dictionary. I don't know why I
chose that. Anyway. Here's the script... And it works. Funnily enough when writing the program I kept having snippets of thoughts on how staying
with your old choice would leave you at 33% anyways since you didn't take advantage of the situation of knowing one door which had a goat behind it
That prompted me to write the normal test where based on intuition, you'd stick with the door you picked originally. And yes, everything checks out.
Edit: I also thought of the case of what if the game host reveals a door behind which there is a goat BEFORE you make your first pick.
Isn't that like the first scenario but the order just reversed? Apparently not. The results move down to 50-50. My mind
@kiriappeee
kiriappeee / Karatsuba.py
Last active August 29, 2015 14:00
Quick implementation of the Karatsuba multiplication algorithm
"""Quick implementation of the Karatsuba multiplication algorithm while doing
the Stanford Algortihms Design and Analysis Part 1 Course"""
def karatsuba(x,y):
if x < 10 and y < 10:
return x*y
else:
if x > y:
divider = pow(10,len(str(x)) / 2)
else:
divider = pow(10,len(str(y)) / 2)
<li class="{{if isCompleted 'completed'}}">
{{#if isEditing}}
{{input type="text" class="edit" value=todo.title focus-out="acceptChanges"
insert-newline="acceptChanges"}}
{{else}}
{{input type="checkbox" checked=todo.isCompleted class="toggle"}}
<label {{action "editTodo" on="doubleClick"}}>{{title}}</label><button class="destroy"></button>
{{/if}}
</li>
@kiriappeee
kiriappeee / day7.py
Created December 11, 2015 06:57
Advent of code day 7 solution (http://adventofcode.com/day/7)
import struct
import re
#NOTE that the input file given below won't be the same if you sign up for advent of code to try it out yourself.
#let me know if it doesn't work for you
circuit = {}
def parseInstruction(instruction):
instructionBreakDown = dict()
if re.search(r'AND|OR', instruction):
result = re.findall(r'(\w+|\d+) (AND|OR) (\w+) -> (\w+)', instruction)[0]
from collections import defaultdict
UNICODE_BLOCKS = {
'en': range(0x0000, 0x02AF),
'si': range(0x0D80, 0x0DFF),
'ta': range(0x0B80, 0x0BFF),
'dv': range(0x0780, 0x07BF)
}
def getlang(text):
@kiriappeee
kiriappeee / bo.pl
Created October 4, 2017 08:35
Trojan that got picked up on computer
#!/usr/bin/perl
# ShellBOT
# 0ldW0lf - oldwolf@atrix-team.org
# - www.atrix-team.org
# Stealth ShellBot Versão 0.2 by Thiago X