Skip to content

Instantly share code, notes, and snippets.

@manicai
manicai / gist:f6ffb5667d6ed2f0930d6faf53cbc1d7
Last active January 8, 2024 17:17
Dumping image data from Chrome
// Typescript
export function dump_image(image: ImageData) {
const canvas = document.createElement("canvas") as HTMLCanvasElement;
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext("2d")!.putImageData(image, 0, 0);
return canvas.toDataURL();
}

Keybase proof

I hereby claim:

  • I am manicai on github.
  • I am manicai (https://keybase.io/manicai) on keybase.
  • I have a public key ASD4YpAORkydnE5bPaIYhuZtg3jKguy9nKkui6_wzsNflwo

To claim this, I am signing this object:

@manicai
manicai / IReceiver.cs
Created January 24, 2014 11:15
Noddy C# IPC with WinForms Example
namespace Receiver
{
using System.ServiceModel;
[ServiceContract]
public interface IReceiver
{
[OperationContract]
void AddLine();
}
@manicai
manicai / SingleInstance.cs
Created October 6, 2011 09:51
Single instance of a application
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace Child
{
@manicai
manicai / sqlserver.cs
Created August 18, 2011 10:00
Creating user and login and associating with role for SQLServer via SMO
// Reference
// Microsoft.SqlServer.ConnectionInfo.dll
// Microsoft.SqlServer.Management.Sdk.Sfc.dll
// Microsoft.SqlServer.SqlEnum.dll
// Microsoft.SqlServer.Smo.dll
// all from %PROGRAM FILES%\Microsoft SQL Server\100\SDK\Assemblies
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
@manicai
manicai / olympics.py
Created May 3, 2011 20:36
Olympic Ticket Inferer
#!/usr/bin/env python
#
# Find prices of all possibilities of ticket allocations in the London
# 2012 Olympic lottery.
#
from itertools import chain, combinations
import re
import fileinput
def remove_pound(s):
@manicai
manicai / gist:937285
Created April 22, 2011 18:15
Simple AutoExp visualizers
class TimePeriod
{
private:
unsigned int value_;
public:
TimePeriod(int days, int months, int years)
{
value_ = days;
value_ += months << 16;
@manicai
manicai / autoexp.dat
Created April 22, 2011 18:08
Useful things to put in your autoexp.dat file for C++ debugging in Visual Studio. I didn't write these but I'm afraid I can't remember where I found them to give credit.
;------------------------------------------------------------------------------
; CArray
;------------------------------------------------------------------------------
CArray<*>|CDWordArray|CWordArray|CByteArray|CUIntArray|CPtrArray|CObArray|CStringArray{
preview
(
#( "[", [$c.m_nSize], "](",
#array
(
expr : $c.m_pData[$i],
@manicai
manicai / kalman.py
Created April 16, 2011 08:33
Simple example of 1 dimensional Kalman filtering in Python
from random import normalvariate
##########################################################################
# "Real world" that we're trying to track
class RealWorld:
def __init__(self):
self.position = 0.0
self.velocity = 0.5
self.time_step = 0.1
self.time = 0.0