https://medium.com/airbnb-engineering/enzyme-javascript-testing-utilities-for-react-a417e5e5090f
This file contains 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
# | |
# Example from code built on the Flask web framework (and Werkzeug) | |
# Accepts uploading a photo file in the 'photo' form member, then | |
# copies it into a memory byte array and converts it to a numpy array | |
# which in turn can be decoded by OpenCV. | |
# | |
# Beware that this increases the memory pressure and you should | |
# configure a max request size before doing so. | |
# | |
# It saves a round-trip to a temporary file, though. |
This file contains 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
@flask.ext.login.user_logged_in.connect_via(app) | |
def when_user_logged_in(sender_app, user): | |
print "user_logged_in %s" % (user) | |
@flask.ext.login.user_logged_out.connect_via(app) | |
def when_user_logged_out(sender_app, user): | |
print "user_logged_out %s" % (user) |
This file contains 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
driver = 'mysql+pymysql://' | |
driver = 'postgresql+psycopg2://' | |
app.config['SQLALCHEMY_DATABASE_URI'] = driver \ | |
+ os.environ['RDS_USERNAME'] + ':' + os.environ['RDS_PASSWORD'] \ | |
+'@' + os.environ['RDS_HOSTNAME'] + ':' + os.environ['RDS_PORT'] \ | |
+ '/' + os.environ['RDS_DB_NAME'] |
This file contains 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
// <Name>Web pages that do not use the AuthorizationService</Name> | |
from t in JustMyCode.Types | |
where t.DeriveFrom("System.Web.UI.Page") | |
from pl in t.Methods | |
where pl.SimpleName == "Page_Load" | |
&& !pl.IsUsingType("Cyberdyne.AuthorizationService") | |
select new { t, t.BaseClass, pl.SimpleName } |
This file contains 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
namespace Functionglot | |
type Customer = { First : string; Last: string; SSN: uint32; AccountNumber : uint32; } | |
type Shape = | |
| Rectangle of width : float * length : float | |
| Circle of radius : float | |
| EquilateralTriangle of side : float | |
| Square of side : float |
This file contains 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
# | |
# Set environment variables for Visual Studio Command Prompt | |
# The technique is to start a Developer Command Prompt and capture its environment into PowerShell | |
# | |
# (VS2013) http://stackoverflow.com/questions/2124753/how-i-can-use-powershell-with-the-visual-studio-command-prompt | |
# (VS2015) https://github.com/jbake/Powershell_scripts/blob/master/Invoke-BatchFile.ps1 | |
# | |
# Add this to your $PROFILE file in PowerShell | |
pushd 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\' |
This file contains 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
// World Bank data example | |
// Look up some indicators for the Nordic markets | |
#r @"..\packages\FSharp.Data.2.2.5\lib\net40\FSharp.Data.dll" | |
open FSharp.Data | |
let wb= WorldBankData.GetDataContext() | |
let countries = [ | |
wb.Countries.Denmark |
This file contains 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
#I "./packages" | |
#r "FParsec/lib/net40-client/FParsec.dll" | |
#r "FParsec/lib/net40-client/FParsecCS.dll" | |
#r "Aether/lib/net35/Aether.dll" | |
#r "Chiron/lib/net40/Chiron.dll" | |
#r "System.Runtime.Serialization" | |
open Chiron |
This file contains 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
// F# FizzBuzz using Active Patterns | |
let (|DivisibleBy|_|) by n = | |
match n%by with | |
| 0 -> Some DivisibleBy | |
| _ -> None | |
let fizzbuzz = function | |
| DivisibleBy 3 & DivisibleBy 5 -> "FizzBuzz" | |
| DivisibleBy 3 -> "Fizz" |