Skip to content

Instantly share code, notes, and snippets.

View ialex32x's full-sized avatar

ialex32x ialex32x

  • Funk Games
  • Shanghai
  • 04:14 (UTC +08:00)
View GitHub Profile
@ialex32x
ialex32x / Mango Tips
Last active December 14, 2015 22:39
mongodb 基本命令
启动 mongodb:
> mongod --dbpath [dir]
# 使用安全认证、指定路径、指定日志地址
> mongod --auth --dbpath /usr/mongo/data --logfile /var/mongo.log
# 关闭服务器
> db.shutdownServer()
# 修复
> mongod --repair
mongodb commands:
@ialex32x
ialex32x / PythonQSort
Last active December 16, 2015 10:08
Python.QSort
import math
import random
data = [1,2,3,4,5,6,7,8,9,0,11,12,13,14,15,16]
def randomize(data):
for i in xrange(0,len(data)*10):
idx1 = random.randint(0, len(data)-1)
idx2 = random.randint(0, len(data)-1)
if idx1!=idx2:
@ialex32x
ialex32x / Downloader Sample
Last active March 11, 2022 07:41
C# simple http download sample
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
using System.Net;
namespace ConsoleApplication1
{
@ialex32x
ialex32x / TouchZoom
Last active December 16, 2015 18:18
detect zoom in/out by 2 touches.
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
public int lastTouchCount;
public float startTouchSpace;
public float thisTouchSpace;
public bool isControl;
@ialex32x
ialex32x / CodeDom.Compiler
Last active December 17, 2015 00:49
C# compiler
using System;
namespace Sample
{
class Test
{
public static System.Reflection.Assembly Compile(string source)
{
var p = new Microsoft.CSharp.CSharpCodeProvider();
var c = p.CreateCompiler();
@ialex32x
ialex32x / X-RAY Effect
Created June 21, 2013 07:19
Unity3D shader scrabble
/*
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _Ramp;
uniform half4 _Color;
struct v2f {
@ialex32x
ialex32x / SocketSecurityServer
Created July 9, 2013 07:20
python implementation of unity socket policy server
#!/usr/bin/python
#description:python implementation of sockpol.cs for Unity corss domain socket security policy.
#last-modified:2012/4/9 14:03
#author:huliangjie
import socket
import select
import threading
import time
@ialex32x
ialex32x / ipy.cs
Last active December 20, 2015 06:19
IronPython basic usage for hosting.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@ialex32x
ialex32x / fsw.cs
Last active May 13, 2019 02:22
c#. file system watcher.
/*
C# 监听文件变化
*/
var fsw = new FileSystemWatcher("../../scripts"); // 监视指定文件夹
fsw.Changed += fsw_Changed; // 注册事件回调
fsw.EnableRaisingEvents = true; // 启用事件通知 (事件异步触发)
/* ================================= */
@ialex32x
ialex32x / replace_all.py
Created June 1, 2017 05:58
replace all occurence
filename_in = "sourcefile.name"
filename_out = "destinationfile.name"
fin = open(filename_in, "r")
fout = open(filename_out, "w")
original_word = "WORD"
replace_by = "DROW"
match_buffer = ""
replace_count = 0