Skip to content

Instantly share code, notes, and snippets.

View felipecsl's full-sized avatar
⚒️
Building

Felipe Lima felipecsl

⚒️
Building
View GitHub Profile
@mmalex
mmalex / pngencode.cpp
Created April 7, 2011 17:48 — forked from anonymous/pngencode.cpp
bug fix png encoder
// by alex evans, 2011. released into the public domain.
// based on a first ever reading of the png spec, it occurs to me that a minimal png encoder should be quite simple.
// this is a first stab - may be buggy! the only external dependency is zlib and some basic typedefs (u32, u8)
//
// VERSION 0.02! now using zlib's crc rather than my own, and avoiding a memcpy and memory scribbler in the old one
// by passing the zero byte at the start of the scanline to zlib first, then the original scanline in place. WIN!
//
// more context at http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/.
//
// follow me on twitter @mmalex http://twitter.com/mmalex
@chrisbanes
chrisbanes / ForegroundLinearLayout.java
Created February 19, 2014 13:16
ForegroundLinearLayout
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@lovubuntu
lovubuntu / Sha256.kt
Created November 24, 2017 15:58
function to generate Sha-256 in Kotlin
Class Hasher {
fun hash(): String {
val bytes = this.toString().toByteArray()
val md = MessageDigest.getInstance("SHA-256")
val digest = md.digest(bytes)
return digest.fold("", { str, it -> str + "%02x".format(it) })
}
}
@luisbebop
luisbebop / install-rbenv-amazon-linux-ami.sh
Created November 26, 2017 16:32
Install rbenv on Amazon Linux AMI
sudo yum install -y git gcc make readline-devel openssl-devel
git clone git://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# Install ruby-build system-widely
git clone git://github.com/rbenv/ruby-build.git /tmp/ruby-build
cd /tmp/ruby-build
@evanbeard
evanbeard / registrations_controller.rb
Created May 11, 2012 19:53 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@diogopms
diogopms / videoinfo.js
Last active October 30, 2023 18:24
Get video information using ffprobe and url
var exec = require('child_process').exec
var url = 'https://URL'
var command =
'curl --silent ' + url + '| ffprobe pipe:0 -print_format json -show_format'
exec(command, function callback (error, stdout, stderr) {
if (stderr.indexOf('Invalid data') > -1) {
console.error('Error!')
}
@Dids
Dids / Compile_Go_for_Apple_Silicon_M1.md
Last active September 25, 2023 01:55
Compile Go for Apple Silicon (M1)

NOTICE: This guide is no longer relevant, as a lot has changed over time and Go supports Apple Silicon natively just fine now!

Compile Go for Apple Silicon (M1)

Follow these short instructions on how to compile Go for Apple Silicon (M1). From here on out, we may simply refer to it as the "ARM device".

This entire process should only take about 5-10 minutes, but please read through everything carefully, in order to avoid any potential issues along the way.

Note that at the time of writing this, Go was not yet officially available for Apple's ARM.

@suicide
suicide / artifactory-get.sh
Last active September 10, 2023 14:27
Downloads latest artifact version from artifactory
#!/bin/bash
# downloads latest version of an artifact from artifactory
set -e
usage(){
echo "Usage: $*" >&2
exit 64
}
@aprock
aprock / RoundedTransformation.java
Created August 12, 2013 18:08
Rounded Corner Image Transformation for square's Picasso
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
// enables hardware accelerated rounded corners
// original idea here : http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/
@JakeWharton
JakeWharton / BindingAdapter.java
Last active July 25, 2023 05:49
An adapter base class that uses a new/bind pattern for its views.
// Apache 2.0 licensed.
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {