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
# Saturday # | |
=== | |
>If you knew you could not fail, what would you do? |
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
void Main() | |
{ | |
var g = new Grid(); | |
var w = new Window { Width = 420, Height = 440, Title = "Graph", Content = g}; | |
var c = new Canvas { Background = Brushes.BlanchedAlmond }; | |
DrawLine(200,10,200,390,c); | |
DrawLine(10,200,390,200,c); | |
double x1 = 150; |
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
//Just a quick code snippet. I was interested in executing javascript from C#. So far, the two clear winners for a framework to do this are JInt and Jurrasic. Needless to say, the V8 Javascript.Net project is dead and doesn't even try to pretend otherwise... | |
//JScript .Net has been dead a long time - let's not even go there. | |
//Jurassic takes a bit more effort to integrate existing .Net objects into scripts as parameters, but makes perhaps is faster. | |
//JInt is the easiest to use and integrate (takes objects directly as parameters) - and for quick DSL-like scripting using Javascript - wins my vote. | |
using Jint; | |
using Jurassic; | |
using Newtonsoft.Json; |
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
// flips.cpp : Defines the entry point for the console application. | |
// | |
#include "time.h" | |
#include "stdio.h" | |
#include "stdlib.h" | |
double f(int, int *i, int *hist); | |
int main(int argc, char* argv[] ) | |
{ |
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
// flipfunc.c : Flips a coin | |
#include "time.h" | |
#include "stdio.h" | |
#include "stdlib.h" | |
double f(int, int *i, int *hist); | |
// Input: flips - how many times to flip the coin. | |
// Output: |
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 math | |
def isprime(n): | |
if n == 2: | |
return True | |
if n == 3: | |
return True | |
if n % 2 == 0: | |
return False | |
if n % 3 == 0: |
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
months = [0, 6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4] | |
def centuryOffset(c): | |
if c / 100 == 21: | |
return -2 | |
if c / 100 == 20: | |
return 0 | |
if c / 100 == 19: | |
return 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
import io | |
f = open('somefile.txt','w') | |
freq = 2 | |
rows = [] | |
rows.append('row a') | |
rows.append('row b') | |
rows.append('row c') | |
rows.append('row d') |
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
// Implements addition using bit operations (an adder) | |
// This was an answer to a playful Koan test for .Net Core. | |
// I resolved not to use google and work it out from basic | |
// boolean math principles. Could probably be simpler, but was | |
// a fun exercise. | |
public void AdditionWithoutPlusOrMinusOperator() | |
{ | |
var adder = new Func<int,int,int>((a,b)=>{ | |
int c = 0; // carry |
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
from math import log2, pow | |
class Tree(): | |
def __init__(this,value=None,left=None,right=None): | |
this.value = value | |
this.left = left | |
this.right = right | |
tree = Tree('*', | |
Tree('-', |
OlderNewer