Skip to content

Instantly share code, notes, and snippets.

View adamczykpiotr's full-sized avatar

Piotr Adamczyk adamczykpiotr

View GitHub Profile
//Timer0
TCCR0B = (TCCR0B & 0b11111000) | 0x01; //62.5 [kHz]
TCCR0B = (TCCR0B & 0b11111000) | 0x02; //7.8125 [kHz]
TCCR0B = (TCCR0B & 0b11111000) | 0x03; //976.5625 [Hz]
TCCR0B = (TCCR0B & 0b11111000) | 0x04; //244.140625 [Hz]
TCCR0B = (TCCR0B & 0b11111000) | 0x05; //61.03515625 [Hz]
//Timer1
TCCR1B = (TCCR1B & 0b11111000) | 0x01; //31.37255 [kHz]
TCCR1B = (TCCR1B & 0b11111000) | 0x02; //3.92116 [kHz]
@rikusalminen
rikusalminen / gist:972e3824350193bbed0c28ff96a82a73
Created September 10, 2016 16:24
Linux force feedback hello world
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <linux/input.h>
@nepsilon
nepsilon / git-change-commit-messages.md
Last active November 19, 2024 18:18
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@dimasch
dimasch / redis-clear
Last active April 8, 2025 15:56
Clear a redis cache in Docker
docker exec -it container-name redis-cli FLUSHALL
@odan
odan / xampp_php7_xdebug.md
Last active April 9, 2025 13:07
Installing Xdebug for XAMPP
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@grexlort
grexlort / phonePrefixCodesWithCountry.php
Last active June 1, 2024 01:45
List of phone prefix codes with country in PHP array format prefix => country +xxx
// data from https://gist.github.com/andyj/7108917
$array = [
'44' => 'UK (+44)',
'1' => 'USA (+1)',
'213' => 'Algeria (+213)',
'376' => 'Andorra (+376)',
'244' => 'Angola (+244)',
'1264' => 'Anguilla (+1264)',
'1268' => 'Antigua & Barbuda (+1268)',
@gchudnov
gchudnov / cpp_utf8_utf16.cpp
Created November 6, 2014 19:33
C++ string conversion UTF8 <-> UTF16
#include <string>
#include <locale>
#include <codecvt>
//UTF-8 to UTF-16
std::string source;
//...
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
std::u16string dest = convert.from_bytes(source);
@CaptainJH
CaptainJH / Iterate days
Last active August 17, 2023 09:42
Output date string in C++
/// iterate from fromD(like "2014-04-02") to toD("2014-05-02")
std::string tpStr = fromD;
do {
//std::cout << tpStr << std::endl;
ParseIntoUserInfoDB(tpStr, root, order);
std::tm tm;
std::stringstream ss(tpStr + " 0:0:1");
ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S");
auto tp = std::chrono::system_clock::from_time_t(std::mktime(&tm));
@paulund
paulund / example-wp-list-table.php
Last active January 28, 2025 16:01
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/