Skip to content

Instantly share code, notes, and snippets.

@synther
synther / gist:eeeb7e5b4596f6ed3774
Created April 11, 2015 16:43
enable right click
#!/bin/bash
if [ $# -ne 1 ]; then
echo "$0 <device id|device name>"
exit 1
fi
i=0
while read label min delim max; do
if [ $i -eq 0 ]; then
@synther
synther / queue.h
Created April 20, 2015 14:06
LIST
/*
* List definitions.
*/
#define LIST_HEAD(name, type) \
struct name { \
struct type *lh_first; /* first element */ \
}
#define LIST_HEAD_INITIALIZER(head) \
{ NULL }
@synther
synther / gist:0393464afc7e755bbe33
Last active August 29, 2015 14:21
3G modem connection
[ 1638.680000] UDP: bad checksum. From 22.68.187.255:59015 to xxx.xxx.my.ip:53 ulen 43
[ 1639.080000] UDP: bad checksum. From 83.134.124.244:8706 to xxx.xxx.my.ip:53 ulen 51
[ 1641.980000] __ratelimit: 11 callbacks suppressed
[ 1641.990000] UDP: bad checksum. From 118.149.245.188:57576 to xxx.xxx.my.ip:53 ulen 51
[ 1641.990000] UDP: bad checksum. From 68.76.24.191:40791 to xxx.xxx.my.ip:53 ulen 51
[ 1642.590000] UDP: bad checksum. From 53.112.49.173:39565 to xxx.xxx.my.ip:53 ulen 51
[ 1643.100000] UDP: bad checksum. From 93.74.202.243:33673 to xxx.xxx.my.ip:53 ulen 43
[ 1643.760000] UDP: bad checksum. From 62.196.183.91:13029 to xxx.xxx.my.ip:53 ulen 47
[ 1643.940000] UDP: bad checksum. From 44.100.134.31:56551 to xxx.xxx.my.ip:53 ulen 43
[ 1644.070000] UDP: bad checksum. From 116.176.222.45:50575 to xxx.xxx.my.ip:53 ulen 43
//#include <SoftwareSerial.h>
//use mega Serial 2 for serial monitor; Serial 1 on pins 19 (RX) and 18 (TX);// Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX).
#define SSID "enter SSID here"
#define PASS "enter password here"
#define DST_IP "220.181.111.85" //baidu.com
//SoftwareSerial dbgSerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
@synther
synther / LambdaTest.java
Created November 23, 2011 17:38
Attempt to make a lambda-like construction in Java
package lambdatest;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Попытка сделать что-то похожее на лямбды не используя паттерн Command.
* Треш, кишки и расчлененка.
*
@synther
synther / roman.scala
Created January 22, 2012 13:00
Из римских чисел в арабские. Пример из книги
def roman(in: List[Char]): Int = in match {
case 'I' :: 'V' :: rest => 4 + roman(rest)
case 'I' :: 'X' :: rest => 9 + roman(rest)
case 'I' :: rest => 1 + roman(rest)
case 'V' :: rest => 5 + roman(rest)
case 'X' :: 'L' :: rest => 40 + roman(rest)
case 'X' :: 'C' :: rest => 90 + roman(rest)
case 'X' :: rest => 10 + roman(rest)
case 'L' :: rest => 50 + roman(rest)
case 'C' :: 'D' :: rest => 400 + roman(rest)
@synther
synther / gist:2631238
Created May 7, 2012 23:00
Java - Unsafe reference publication
class Data {
private Object ob1 = new Object();
private Object ob2 = new Object();
private Object ob3 = new Object();
private Object ob4 = new Object();
@synther
synther / 1 - Program.java
Created July 22, 2012 19:14
Implementing a method wrapper (using java.lang.reflect.Proxy)
package com.inalgebra.proxytest;
import com.inalgebra.proxy.MethodWrapper;
import java.lang.reflect.Method;
/**
* Created with IntelliJ IDEA.
* User: synther
* Date: 7/22/12
out_curr[3] = ((new_nal_len >> 0) & 0xFF); // move byte 3 to byte 0
b384: e59d302c ldr r3, [sp, #44] ; 0x2c
b388: e2832003 add r2, r3, #3
b38c: e59d3034 ldr r3, [sp, #52] ; 0x34
b390: e20330ff and r3, r3, #255 ; 0xff
b394: e5c23000 strb r3, [r2]
out_curr[2] = ((new_nal_len >> 8) & 0xFF); // move byte 2 to byte 1
b398: e59d302c ldr r3, [sp, #44] ; 0x2c
b39c: e2832002 add r2, r3, #2
b3a0: e59d3034 ldr r3, [sp, #52] ; 0x34
@synther
synther / hierarchic
Last active December 11, 2015 09:29
Реализация метода анализа иерархий для принятия решений в условиях неопределенности. Предполагаем, что весовые коэффициенты уже известны
/**
* Created with IntelliJ IDEA.
* User: Synther
* Date: 20.01.13
* Time: 14:19
*/
abstract class Node
case class Criterion(weight: Double, child: List[Node]) extends Node
case class Alternative(weights: List[Double]) extends Node