Skip to content

Instantly share code, notes, and snippets.

View AchrafAmil's full-sized avatar
🧑‍💻

Achraf AchrafAmil

🧑‍💻
View GitHub Profile
@clementgarbay
clementgarbay / collections.kt
Created April 21, 2018 10:34
Safe transpose a list of unequal-length lists in Kotlin.
/**
* Safe transpose a list of unequal-length lists.
*
* Example:
* transpose(List(List(1, 2, 3), List(4, 5, 6), List(7, 8)))
* -> List(List(1, 4, 7), List(2, 5, 8), List(3, 6))
*/
fun <E> transpose(xs: List<List<E>>): List<List<E>> {
// Helpers
fun <E> List<E>.head(): E = this.first()
@fearphage
fearphage / .gitconfig
Last active November 26, 2018 15:13
When you need to save the code before you save yourself, git fire.
[alias]
fire = !"f() { \
local current_branch=$(basename \"$(git symbolic-ref HEAD)\"); \
local new_branch=fire-${current_branch}-$(git config user.email)-$(date +%s) \
local message; \
if [ -z \"$1\" ]; then \
message=\"fire commit from $current_branch\"; \
else \
message=\"$*\"; \
fi; \
@KANGOD
KANGOD / build.gradle
Created February 24, 2016 03:39
Generate signed and aligned apk without putting keystore info in build.gradle. via http://stackoverflow.com/a/20573171/1819810
android {
// omitting...
signingConfigs {
release {
readKeystoreProperties()
}
}
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@kboyarshinov
kboyarshinov / checkstyle.gradle
Last active June 18, 2024 13:23
Code quality gradle scripts for Android
/**
* Checkstyle tasks
* Usage:
* - place this file under root dir of your project at /gradle directory
* - apply script from your gradle file:
* apply from : "{rootDir}/gradle/checkstyle.gradle"
*
* To configure checkstyle use configs at:
* "{rootDir}/config/checkstyle/checkstyle.xml" - for main projects
* "{rootDir}/config/checkstyle/checkstyle-test.xml" - for tests
@Thermionix
Thermionix / userDefineLang_Groovy.xml
Last active February 3, 2025 16:37
Groovy user defined language for notepad++
<NotepadPlus>
<UserLang name="Groovy" ext="groovy" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03/* 04*/ 00// 01 02</Keywords>
<Keywords name="Keywords1">abstract break case catch continue default do else extends final finally for if implements instanceof native new private protected public return static switch synchronized throw throws transient try volatile while strictfp package import false null super this true</Keywords>
<Keywords name="Keywords2">as assert def mixin property test using in it</Keywords>
@decnorton
decnorton / Android - File SHA1 check
Last active August 22, 2016 08:48
Android. Check the SHA1 of a file against a string
public static boolean testSHA1(String sha1, File file) {
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException e) {
Log.e(TAG, "Exception while getting Digest", e);
return false;
}
InputStream is;
@zudov
zudov / BodyEditorLoader.java
Last active May 13, 2019 23:52
That is a version of loader for physic-body-editor that works with new JSON API from libgdx nightlies.
package aurelienribon.bodyeditor;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.JsonReader;