Skip to content

Instantly share code, notes, and snippets.

View korniltsev's full-sized avatar
🏳️‍🌈
s/jz/jnz/

Tolya Korniltsev korniltsev

🏳️‍🌈
s/jz/jnz/
View GitHub Profile
@lazyval
lazyval / brackets.scala
Created October 3, 2012 17:53
bracket balanicing
object Main extends App {
println(isBalanced("(.)(.)".toList))
def isBalanced(list: List[Char]) = {
@annotation.tailrec
def countBracets(string: List[Char], count: Int = 0): Int = {
string match {
case '('::tail => countBracets(tail, count+1)
case ')'::tail => countBracets(tail, count-1)
/*
* Copyright (C) 2016 Jesse Wilson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@chetbox
chetbox / count_apk_methods.sh
Last active October 22, 2016 16:11
Method count of multidex APK one-liner
apk=app.apk count=0 ; for dex in $(unzip -Z1 $apk classes*.dex); do count=$(($count + $(unzip -p $apk $dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'))) ; done ; echo $count
@dsaenztagarro
dsaenztagarro / vagrant_config_locale.md
Last active September 25, 2018 20:20
Fix vagrant boxes locale settings

Add these lines to the bottom of the file:

# ~/.bashrc
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

After editing the file execute this commands

@inaz2
inaz2 / fastbins_malloc_hook.c
Last active January 6, 2020 12:05
overwrite malloc_hook by fastbins unlink attack
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void jackpot() { puts("jackpot!"); }
int main()
{
puts("[+] allocate p1, p2");
char *p1 = malloc(0x100);
@hrydgard
hrydgard / OpenSLWrap.cpp
Created July 8, 2012 19:48
A minimal implementation of audio streaming using OpenSL in the Android NDK
// Minimal audio streaming using OpenSL.
//
// Loosely based on the Android NDK sample code.
// Hardcoded to 44.1kHz stereo 16-bit audio, because as far as I'm concerned,
// that's the only format that makes any sense.
#include <assert.h>
#include <string.h>
// for native audio
@Dliv3
Dliv3 / qemu-2.7.0-aslr_heap_pie_nx_wxorx_mmap.patch
Created March 20, 2019 07:52 — forked from grimmlin/qemu-2.7.0-aslr_heap_pie_nx_wxorx_mmap.patch
Qemu aslr, heapaslr, pie, NX and W^X implementation (NX only for arm and mips atm)
diff -Naur qemu-2.7.0.orig/cpu-exec.c qemu-2.7.0/cpu-exec.c
--- qemu-2.7.0.orig/cpu-exec.c 2016-09-02 17:34:17.000000000 +0200
+++ qemu-2.7.0/cpu-exec.c 2017-01-19 09:34:00.817088525 +0100
@@ -33,6 +33,9 @@
#include "hw/i386/apic.h"
#endif
#include "sysemu/replay.h"
+#include "syscall_defs.h"
+
+extern int do_nx;
@FrancoisBlavoet
FrancoisBlavoet / GammaEvaluator.java
Last active November 17, 2020 07:03
Correct color interpolation
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import static java.lang.Math.pow;
public class GammaEvaluator implements TypeEvaluator {
private static final GammaEvaluator instance = new GammaEvaluator();
/**
@rubenlagus
rubenlagus / Main.java
Last active May 31, 2021 13:22
Example of sending a SendMessage method using Telegram API with ReplyMarkupKeyboard
package org.telegram.example.SendMessage;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
@shahril96
shahril96 / z3_prime.py
Last active June 25, 2021 00:16
Generating list of valid prime numbers using Z3 theorem prover
'''
Using Z3 to check if the number is prime
Original reference: https://stackoverflow.com/a/35653749/1768052
'''
from z3 import *
def isPrime(x):
y, z = Ints("y z")