Skip to content

Instantly share code, notes, and snippets.

View arlm's full-sized avatar

Alexandre Rocha Lima e Marcondes arlm

View GitHub Profile
@arlm
arlm / BigDecimal.cs
Created February 20, 2017 16:45 — forked from nberardi/BigDecimal.cs
BigDecimal type in .NET
using System;
using System.Linq;
namespace System.Numerics
{
public struct BigDecimal : IConvertible, IFormattable, IComparable, IComparable<BigDecimal>, IEquatable<BigDecimal>
{
public static readonly BigDecimal MinusOne = new BigDecimal(BigInteger.MinusOne, 0);
public static readonly BigDecimal Zero = new BigDecimal(BigInteger.Zero, 0);
public static readonly BigDecimal One = new BigDecimal(BigInteger.One, 0);
@arlm
arlm / unzip.ps1
Created February 21, 2017 11:14 — forked from nachivpn/unzip.ps1
Unzip a file in powershell by overwriting existing files
function Unzip($zipfile, $outdir)
{
Add-Type -AssemblyName System.IO.Compression.FileSystem
$archive = [System.IO.Compression.ZipFile]::OpenRead($zipfile)
foreach ($entry in $archive.Entries)
{
$entryTargetFilePath = [System.IO.Path]::Combine($outdir, $entry.FullName)
$entryDir = [System.IO.Path]::GetDirectoryName($entryTargetFilePath)
#Ensure the directory of the archive entry exists
@arlm
arlm / GAME_API.lua
Created March 1, 2017 21:34 — forked from rndstr/GAME_API.lua
jserver API && example game
-- * attach functions to our existing cGame class. ('cGame:_blah') Use a preceeding underscore to make sure there is no name clash.
-- * access the game instance through 'g'
-- * access global exported C++ functions:
-- j_log( string )
-- write to jserver log stream (you may not use '\n', a newline is appended automatically on each function call)
-- NOTE: for tablelog use g:log() and g:log_debug()
-- j_stackdump() -- dumps the stack
--
-- * convention:
-- send_* - needs the client_idx as first argument (NOTE not id!)
@arlm
arlm / shareWithoutFacebook
Created March 2, 2017 05:36 — forked from suau/shareWithoutFacebook
share text to android applications except facebook
public static void shareWithoutFacebook(Context context, String text) {
// get available share intents
List<Intent> targets = new ArrayList<>();
Intent template = new Intent(Intent.ACTION_SEND);
template.setType("text/plain");
List<ResolveInfo> resolveInfos = context.getPackageManager().
queryIntentActivities(template, 0);
// remove facebook which has a broken share intent
for (ResolveInfo resolveInfo : resolveInfos) {
@arlm
arlm / gist:7e5d9b6b22c445f1bdce8497b6a35dc2
Created March 2, 2017 05:37 — forked from tajchert/gist:73422616624090851fa5
Due to Facebook not handling any text in share intent (ACTION_SEND), and not trying to fix it (it is a "feature"), lets remove it from share dialog - as otherwise it results in broken user experience and most likely users will blame us not the Facebook. Bug on Facebook issue tracker https://developers.facebook.com/bugs/332619626816423
// Usage:
// your share intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject");
// invoke custom chooser that contains all apps just without Facebook
startActivity(Tools.customChooserIntentNoFb(intent, "Share using", context));
// Method:
Expression<Func<string, bool>> f = s => s.Length < 5;
ParameterExpression p = Expression.Parameter (typeof (string), "s");
MemberExpression stringLength = Expression.Property (p, "Length");
ConstantExpression five = Expression.Constant (5);
BinaryExpression comparison = Expression.LessThan(stringLength, five);
Expression<Func<string, bool>> lambda = Expression.Lambda<Func<string, bool>> (comparison, p);
Func<string, bool> runnable = lambda.Compile();
@arlm
arlm / IIS-Functions.ps1
Created March 7, 2017 12:56 — forked from sergejusb/IIS-Functions.ps1
Basic Power-Shell cmdlets to work with IIS 7+
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# IIS functions
Import-Module WebAdministration
function Test-WebAppPool($Name) {
return Test-Path "IIS:\AppPools\$Name"
}
function Get-WebAppPool($Name) {

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@arlm
arlm / useful_pandas_snippets.py
Created December 12, 2017 12:46 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@arlm
arlm / qemu_osx_rpi_raspbian_jessie.sh
Created January 24, 2018 14:03 — forked from hfreire/qemu_osx_rpi_raspbian_jessie.sh
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (El Capitan)
# Install QEMU OSX port with ARM support
sudo port install qemu +target_arm
export QEMU=$(which qemu-system-arm)
# Dowload kernel and export location
curl -OL \
https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
export RPI_KERNEL=./kernel-qemu-4.1.7-jessie
# Download filesystem and export location