Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mecab
mecab / MainPage.xaml.cs
Created May 27, 2012 07:01
Sample code of fixing strange slider behivor with GestureService (code-behind)
using System.Windows.Input;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework.Input.Touch;
namespace SliderWithGestureService {
public partial class MainPage : PhoneApplicationPage {
// Constructor
public MainPage() {
InitializeComponent();
}
@mecab
mecab / MainPage.xaml
Created May 27, 2012 07:02
Sample code of fixing strange slider behivor with GestureService
<phone:PhoneApplicationPage
x:Class="SliderWithGestureService.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tookit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
@mecab
mecab / cv4.py
Created June 1, 2012 04:36
cv4
import itertools
image = [[10,10,10,10,10,10,10,10,10],
[10,10,10,10,10,10,10,10,10],
[10,10,10,10,10,250,250,250,250],
[10,10,10,10,10,250,250,250,250],
[10,10,250,250,250,250,250,250,250],
[10,10,10,250,250,250,250,250,250],
[10,10,10,10,250,250,250,250,250],
[10,10,10,10,250,250,250,250,250],
<common:LayoutAwarePage
x:Name="pageRoot"
x:Class="App1.SearchResultsPage"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:common="using:App1.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@mecab
mecab / mactype.ini
Created November 19, 2012 09:24
My MacType configuration.
[General]
HintingMode=2
AntiAliasMode=1
NormalWeight=8
BoldWeight=0
ItalicSlant=0
EnableKerning=1
GammaMode=0
LcdFilter=1
BolderMode=0
@mecab
mecab / myitertools.py
Last active December 11, 2015 11:48
A custom iterators for me :D
import itertools
import math
def defer(l, num_defer=1):
"""
>>> [x for x in defer([0, 1, 2, 3])]
[[0, 1], [1, 2], [2, 3]]
>>> [x for x in defer([0, 1, 2, 3], 2)]
[[0, 2], [1, 3]]
@mecab
mecab / my-window-resizer.l
Last active December 11, 2015 22:58
window-resizer ( http://d.hatena.ne.jp/mooz/20100119/p1 )のxyzzy移植版
(defun my-window-resizer ()
"Control window size and position."
(interactive)
(let ((window-obj (selected-window))
(current-width (window-width))
(current-height (window-height))
(dx (if (= (nth 0 (window-coordinate)) 0) 1
-1))
(dy (if (= (nth 1 (window-coordinate)) 0) 1
-1))
@mecab
mecab / dft.py
Last active December 14, 2015 07:58
DFT
import cmath
I = 1j
data = [ cmath.sin(cmath.pi * 2 * x / 16.0) + 1 for x in xrange(16)]
def dft_gen(data):
return (_sum_xk(data, j) for j in xrange(len(data)))
import cmath
def fft(data):
data = data[:] # copy data to avoid side effect
N = len(data)
w = calc_coefficients(N)
reorder_data(data)
a = 1
from django.utils import simplejson as json
class SerializeMethod(object):
def __init__(self):
self.type = type_
self.func = func
class CustomJSONEncoder(json.JSONEncoder):