Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile
@FedericoPonzi
FedericoPonzi / CI.yml
Last active Apr 25, 2020
Ready to use Github workflow for cross-compiling a rust binary to many Linux architectures.
View CI.yml
# Instruction + template repo: https://github.com/FedericoPonzi/rust-ci
# Search and replace <YOUR_BINARY_NAME> with your binary name.
name: CI
on:
pull_request:
push:
branches:
- master
tags:
@joseluisq
joseluisq / stash_dropped.md
Last active Nov 20, 2020
How to recover a dropped stash in Git?
View stash_dropped.md

How to recover a dropped stash in Git?

1. Find the stash commits

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

@lopspower
lopspower / README.md
Last active Sep 25, 2020
Android Tools Attributes
View README.md

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
View CutLayout.java
package com.example.marcin.splitlayout;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Region;
@TWiStErRob
TWiStErRob / OkHttpProgressGlideModule.java
Last active May 12, 2020
Full POC for showing progress of loading in Glide v3 via OkHttp v2
View OkHttpProgressGlideModule.java
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@spalladino
spalladino / mysql-docker.sh
Created Dec 22, 2015
Backup and restore a mysql database from a running Docker mysql container
View mysql-docker.sh
# 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
@kilhage
kilhage / nginx-gzip.conf
Created Dec 4, 2015
Enables gzip compression for common mime types in nginx
View nginx-gzip.conf
# most people include something like this. don't.
# check your default nginx.conf, it's already covered in a much better way.
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
# compress proxied requests too.
# it doesn't actually matter if the request is proxied, we still want it compressed.
gzip_proxied any;
# a pretty comprehensive list of content mime types that we want to compress
# there's a lot of repetition here because different applications might use different
@yang-wei
yang-wei / note.md
Last active Mar 27, 2020
Vue.js tips and tricks
View note.md

Notes: All the examples below are only tested on Vue.js 1.0 (above).

Notes: The examples below use ES6 so it's recommended to use browserify or webpack to easily integrate babel.

when or where can we use this.$el

When you need to access DOM attribute, be careful with the lifecycle. Vue.js has a few useful lifecycle hooks.

Let's say we want to scroll our component to the bottom (imagine it's a long list with overflow-y: auto) once it's instantiate.

View HeaderFooterAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by benny on 15/10/15.
*/
public abstract class HeaderFooterAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public static final int FOOTER = 8769;
@ArthurSav
ArthurSav / WrapGridLayoutManager.java
Created Sep 11, 2015
GridLayoutManager with working wrap_content.
View WrapGridLayoutManager.java
package com.inperson.android.utils.leastview;
import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
public class WrappableGridLayoutManager extends GridLayoutManager {
You can’t perform that action at this time.