Skip to content

Instantly share code, notes, and snippets.

View SammyVimes's full-sized avatar
🗿
I am a teapot

Semyon Danilov SammyVimes

🗿
I am a teapot
  • Nebius (working on YDB distributed database)
  • block-4-2 static blobstorage group
View GitHub Profile
@SammyVimes
SammyVimes / gist:92c0627195c4c55ea800
Created September 16, 2015 10:47
Get REAL orientation in android
private int getScreenOrientation() {
final WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
int rotation = wm.getDefaultDisplay().getRotation();
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
int orientation;
// if the device's natural orientation is portrait:
@SammyVimes
SammyVimes / lastfm cleaner
Created October 17, 2015 15:42
I forgot to turn off the music while I was at work, which resulted in 1500 identical scrobbles. So I wrote this.
var id = setInterval(function () {
var val = jQuery(".metadata-display").text();
val++;
val--;
console.log("Left: " + val);
if (val <= 0) {
clearInterval(id);
return;
}
@SammyVimes
SammyVimes / MAL material design
Last active November 1, 2015 12:52
MAL material design
[class^="status"]:first-child{
border-radius: 10px 0px 0px 0px;
-moz-border-radius: 10px 0px 0px 10px;
-webkit-border-radius: 10px 0px 0px 10px;
-ms-border-radius: 10px 0px 0px 10px;
}
[class="category_totals"]{
border-bottom: 1px solid #B3B3B3;
border-right: 1px solid #E5E5E5;
@SammyVimes
SammyVimes / CloudFlareBypassEngine.java
Created December 26, 2015 20:49
cloudflare ownage
package com.danilov.supermanga.core.repository;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.danilov.supermanga.core.http.ExtendedHttpClient;
import com.danilov.supermanga.core.util.IoUtils;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
@SammyVimes
SammyVimes / zz.js
Last active January 16, 2016 17:54
xx
function update(){fpsCount++,bOnSurface&&(sprite.src=hoizontal_motion_direction==MOTION_RIGHT?GRAPHICS.standing_right:GRAPHICS.standing_left),keysDown.indexOf(DOWN)<0&&(bAttemptingToWarp=!1);for(key in keysDown)switch(keysDown[key]){case RIGHT:posX+=current_speed,stage.scrollLeft<WORLD_SIZE&&(stage.scrollLeft=sprite.offsetLeft-stage.offsetWidth/2+sprite.offsetWidth/2),sprite.src=GRAPHICS.running_right,hoizontal_motion_direction=MOTION_RIGHT;break;case JUMP:bOnSurface&&bCanJump&&(bCanJump=!1,setTimeout(function(){bCanJump=!0},GROUNDED_TIMER),gravity_const=-jump_height,posY-=jump_height,bOnSurface=!1,sprite.src=hoizontal_motion_direction==MOTION_RIGHT?GRAPHICS.jumping_right:GRAPHICS.jumping_left);break;case LEFT:sprite.src=GRAPHICS.running_left,posX-=current_speed,stage.scrollLeft=sprite.offsetLeft-stage.offsetWidth/2+sprite.offsetWidth/2,hoizontal_motion_direction=MOTION_LEFT;break;case DOWN:bOnSurface&&(bAttemptingToWarp=!0)}theta++;for(e in elevators)elevators[e].style.top=175+45*Math.sin(theta/80)+"px";coll
@SammyVimes
SammyVimes / centrifugo.sh
Created February 15, 2016 15:55
centrifugo config
#!/bin/bash
sudo docker run -v /centrifugo:/centrifugo -p 8001:8000 fzambia/centrifugo centrifugo -w > log.txt &
#-v "соединяет" папку на хосте с папкой в контейнере. config.json у меня лежит в /centrifugo
#и я хочу, чтобы эта папка так же была доступна в контейнере (по такому же пути)
sleep 3
echo $! >/home/semyon/script/centrifugal.pid
sudo docker ps -l -q >/home/semyon/script/docker.pid
@SammyVimes
SammyVimes / gist:ab24b44ca25534f4f8c8
Created February 25, 2016 13:58
Get all launcher (homescreen) apps in android
PackageManager pm = ctx.getPackageManager();
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
i.addCategory(Intent.CATEGORY_DEFAULT);
List l = pm.queryIntentActivities(i, 0);
//
// пример базовых морфологических преобразований
// cvErode() и cvDilate()
//
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
@SammyVimes
SammyVimes / mindfuck optimizations
Created March 3, 2016 20:58
minfuck optimizations
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.00.23026.0
include listing.inc
INCLUDELIB OLDNAMES
EXTRN __security_check_cookie:PROC
PUBLIC main
PUBLIC ?simps@@YANNNN@Z ; simps
PUBLIC ?dfx@@YANN@Z ; dfx
@SammyVimes
SammyVimes / gist:671de171db6eaeac0c76
Created March 21, 2016 22:41
imagemagick to negate images
for %a in (*.png) do convert -negate %a %a_dark.png