Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️

Aleksei Cherepanov ftp27

🛠️
View GitHub Profile
@ftp27
ftp27 / CropImage.py
Last active Aug 29, 2015
Crop Image By Transparent Spaces
View CropImage.py
from PIL import Image, ImageDraw
def checkX(image, x):
pixels = image.load()
sum = 0;
for i in range(image.size[1]):
if (pixels[x,i][3] == 0):
sum += 1
return (sum == image.size[1])
@ftp27
ftp27 / genIconForIOS.sh
Created Feb 3, 2015
Generate icon set for iOS
View genIconForIOS.sh
#!/bin/bash
function createDir {
if [ ! -d $1 ]; then
mkdir $1
fi
}
createDir ios
@ftp27
ftp27 / ConvertImages.sh
Last active Aug 29, 2015
Create Android image set
View ConvertImages.sh
#!/bin/bash
function createDir {
if [ ! -d $1 ]; then
mkdir $1
fi
}
createDir imageset
createDir imageset/drawable-xxxhdpi
@ftp27
ftp27 / STM32L_USART1.c
Created Apr 11, 2014
Echo with USART1 on STM32L-Discovery
View STM32L_USART1.c
#include "stm32l1xx.h"
int main(void)
{
RCC->CR |= RCC_CR_HSEON;
while(!(RCC->CR & RCC_CR_HSERDY));
RCC->APB2ENR |= RCC_APB2ENR_USART1EN; //USART1 Clock ON
USART1->BRR = 0xD05; // Bodrate for 9600 on 32Mhz
USART1->CR1 |= USART_CR1_UE | USART_CR1_TE | USART_CR1_RE; // USART1 ON, TX ON, RX ON
@ftp27
ftp27 / STM32L_Blink_Led.c
Last active Oct 7, 2018
Code for blinking led on board STM32L-Discovery
View STM32L_Blink_Led.c
@ftp27
ftp27 / gist:8782988
Created Feb 3, 2014
RFID_RC522.ino
View gist:8782988
/*
* Name:RFID.pde
* Create:www.electrodragon.com
* Create date:2011.09.19
* Function:Mifare1 searching card →prevent conflict→ select card →read write pins
*/
// the sensor communicates using SPI, so include the library:
#include <SPI.h>
#define uchar unsigned char
@ftp27
ftp27 / STM32makefile.sh
Created Jan 5, 2014
MakeFile for STM32L
View STM32makefile.sh
##############################################################################################
#
# On command line:
#
# make all = Create project
#
# make clean = Clean project files.
#
# To rebuild project do "make clean" and "make all".
#
@ftp27
ftp27 / Prepare4djvu.sh
Last active Jan 2, 2016
Crop and rotate scaned pages
View Prepare4djvu.sh
#!/bin/bash
WIDTH="2880";
HEIGHT="1868";
SHIFT_X="880";
SHIFT_Y="608";
ORIENT="left";
# If right page - first, insert "1", otherwise "0"
RIGHT_FIRST="1";
@ftp27
ftp27 / mov2gif.sh
Last active Jan 2, 2016
Convert MOV or some else video to gif animation
View mov2gif.sh
#!/bin/bash
ffmpeg -i video.MOV -r 6 image_%010d.png;
mkdir resized;
for i in image_*.png; do convert $i -resize 600 resized/$i; done
rm -f image_*.png;
cd resized;
convert -delay 10 -layers optimize *.png ../animation.gif
cd ..;
rm -fr resized;
View gist:5896465
#!/usr/bin/python
import os
listRoms = os.listdir(".");
countRoms = len(listRoms);
for i in range(0, countRoms):
name = listRoms[i];
if (name[-4:] == ".bin"):