Skip to content

Instantly share code, notes, and snippets.

private delegate void NoArgDelegate();
public static void Refrsh(DependencyObject o)
{
o.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Loaded, (NoArgDelegate)delegate { });
}
@andor44
andor44 / Timer.hx
Created April 24, 2012 13:41
haxe pseudo-timer for neko
package ;
import neko.vm.Thread;
import neko.Sys;
/**
* ...
* @author Andor
*/
@andor44
andor44 / gist:3049657
Created July 4, 2012 21:33
Type switching
if (Reflect.hasField(settings, split[0]))
{
switch (Type.getClassName(Type.getClass(Reflect.field(settings, split[0]))))
{
case "String":
Reflect.setField(settings, split[0], split.slice(1).join(" "));
case "Array":
Reflect.setField(settings, split[0], split.slice(1));
default:
if (Type.typeof(Reflect.field(settings, split[0])) == ValueType.TBool)
match sdl::event::poll_event() {
sdl::event::QuitEvent => break main,
sdl::event::NoEvent => break event,
sdl::event::KeyEvent { Key: key, _ } => {
match key {
AKey => {}
_ => {}
}
}
_ => {}
@andor44
andor44 / Main.cs
Created March 10, 2013 21:15
számösszeg
using System;
namespace teststuff
{
class Program
{
static ulong szamjegy_osszeg(ulong x)
{
ulong ossz = 0;
ulong lim = (ulong)Math.Ceiling(Math.Log10(x));
@andor44
andor44 / Program.cs
Last active December 14, 2015 19:28
using System.Linq;class p{static void Main(){System.IO.File.ReadAllLines("a.txt").Select(x=>x.Substring(0,x.TakeWhile(y=>y==' ').Count())+x.TrimStart(' ').Split(' ').Where(y=>y!="").Aggregate("",(y,w)=>(y+=w+" ")).TrimEnd(' ')).ToList().ForEach(System.Console.WriteLine);}}
// on windows 7 64bit, the following program produces this output:
//D:\dev\rust>test.exe
//test4
//test1
//^C
//D:\dev\rust>
extern mod std;
unsafe {
let namelen = GetWindowTextLengthA(wh);
let mut namebuf : ~[u8] = std::vec::with_capacity((namelen+2) as uint);
GetWindowTextA(wh, namebuf.as_mut_ptr() as *mut i8, namelen+1);
namebuf.set_len(namelen as uint);
println!("Window: {:s}", match std::str::is_utf8(namebuf) {
true => std::str::from_utf8(namebuf),
false => "Non-UTF8 win name"}
);
}
// foo.rs
use bar::KeyBytes;
mod bar;
fn main() {
...
// baz is some PublicKey
baz.key_bytes(); // PublicKey does not implement any method named key_bytes, but it does?
...
}
impl<T: Encoder> Encodable<T> for NonceWrap {
fn encode(&self, e: &mut T) {
// TODO
}
}