Skip to content

Instantly share code, notes, and snippets.

View peat-psuwit's full-sized avatar

Ratchanan Srirattanamet peat-psuwit

View GitHub Profile
function find(obj) {
//what argument do I have?
console.log(obj);
}
var req = {
body: {
username: "peat",
password: "123456"
}
@peat-psuwit
peat-psuwit / dont-change-format.patch
Created December 20, 2016 09:04
Patch to prevent Mir client on android to change pixel format to something Mir server didn't expect.
--- mir-0.24.1+15.04.20160928.orig/src/platforms/android/client/egl_native_surface_interpreter.cpp
+++ mir-0.24.1+15.04.20160928/src/platforms/android/client/egl_native_surface_interpreter.cpp
@@ -59,7 +59,9 @@
void mcla::EGLNativeSurfaceInterpreter::dispatch_driver_request_format(int format)
{
- driver_pixel_format = format;
+ if (driver_pixel_format == -1 || driver_pixel_format == 0 || format == 0)
+ driver_pixel_format = format;
+ //TODO: pass format changes to server
@peat-psuwit
peat-psuwit / wrongWay.c
Created October 13, 2016 17:15
Wrong way to update binary file (don't do this at home)
#include <stdio.h>
#include <stddef.h>
typedef struct {
char name[128];
int max_hp;
int current_hp;
} Charactor;
#define SAVE_FILENAME "gamedata.bin"
@peat-psuwit
peat-psuwit / myWay.c
Last active October 13, 2016 15:45 — forked from anonymous/myWay.c
Works way to update binary (harder then you think)
#include <stdio.h>
#include <stddef.h>
typedef struct {
char name[128];
int max_hp;
int current_hp;
} Charactor;
#define SAVE_FILENAME "gamedata.bin"
var _ = require('lodash');
function sumSeq(data) {
var groups = _(data).groupBy('group').map(function(value) {
return {
members: _.orderBy(value, ['seq'], ['desc']),
sumSeq: _.sumBy(value, 'seq')
};
}).orderBy(['sumSeq'], ['desc']).value();
#include <stdio.h>
int main() {
int input, tmp;
int reversedInput = 0;
printf("A number: ");
scanf("%d", &input);
tmp = input;
//Eliminate all whitespaces possible give me 820 bytes. Long way to target....
class ExtraPledge {
public static void main(String[] args) throws java.io.IOException{
byte[]a=new byte[790];
Runtime.getRuntime().exec(
new String[]{
"sh",
"-c",
"echo H4sICMN1mFYCA2EAbZJNjtswDIX3OgV3aYFpLlG0QHoLWqJjorLoinQ8vn0p2ZkfYJamqY987/EGS6Z0J7AJDehBdYelyr3iDBvbBPMOBWcCKcAGOmHOMBBslc2owLDDTOEbltQ6o/zA1Sap+gI8Apb9O7RfHX6Dcc15h7UkqmpHnZ7TruHXp+E30HWYP46kYlzJAT5ItgKb1L8Oy6QK4qS6sVJAs8rDapSuzvg0y3fAiIlmjpBYJymk5vLEXJ1zucS8JtIQZdm53A8qLCTu0UX7wBdwNmBWARzIrLWBVBgxcmbDVni+v8JPSaezrKA8c8YKJs2YE95FqrLbu6BaQy2V1LWGjV33ncwXhFgpuRebo1pG3Th6XTIWnyjlK6ne4osUpX8rlegBjl+q98UQ3PHUOy6/LzDKwY8ZVZ0cnhcikOghRi0AGr3NtBUzYS3Nhz/4wHYQ7Tba95FTOBNtqDNM9YgeHeixYrsjO78TGXLuN9Mob9ehoWt6iyrKvHCm3kivFD1vr9VK0fJ+ZlTdIlTOe3i3Bgd/1G52V8pjf36GfMyZve8a/gOvst2vFQMAAA|base64 -d|gzip -cd"
}
@peat-psuwit
peat-psuwit / TOI10-Prime.c
Created May 14, 2014 14:43
เฉลยข้อ Prime ตัวที่ n การแข่งขัน TOI10
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
unsigned int *primes;
unsigned int primesCount=1, primesLimit=16;
unsigned int primeNeeded;