This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# I wrote this script to change the encoding of a large | |
# source code repository with inconsistent file encoding | |
SOURCE_DIR=$1 | |
FILE_MASK="*.$2" | |
DESTINATION_ROOT=$3 | |
if [ $# -ne 3 ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Converts files to the given encoding. | |
Matches the include pattern recursively under the given path. | |
.EXAMPLE | |
Convert-FileEncoding -Include *.js -Path scripts -Encoding UTF8 | |
#> | |
function Convert-FileEncoding([string]$Include, [string]$Path, [string]$Encoding='UTF8') { | |
$count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adapted to BR phone format from the class | |
* UsPhoneNumberFormatter by Samik Bandyopadhyay: | |
* http://stackoverflow.com/a/23659268/332839 | |
*/ | |
public class BrPhoneNumberFormatter implements TextWatcher { | |
final int MAX_LENGTH = 11; | |
//This TextWatcher sub-class formats entered numbers as (41) 1234(5)?-6789 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- * 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!) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
# IIS functions | |
Import-Module WebAdministration | |
function Test-WebAppPool($Name) { | |
return Test-Path "IIS:\AppPools\$Name" | |
} | |
function Get-WebAppPool($Name) { |