Edit: This list is now maintained in the rust-anthology repo.
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
| class TutorialHome extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| // Scafold is a layout for the major material design widgets. | |
| return new Scaffold( | |
| appBar: new AppBar( | |
| leading: new IconButton( | |
| icon: new Icon(Icons.menu), | |
| tooltip: 'Navigation menu', | |
| onPressed: null, |
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
| // Faster solution for: | |
| // http://www.boyter.org/2017/03/golang-solution-faster-equivalent-java-solution/ | |
| // With threading. | |
| // g++ -std=c++11 -Wall -Wextra -O3 -pthread | |
| // On my computer (i5-6600K 3.50 GHz 4 cores), takes about ~160 ms after the CPU | |
| // has warmed up, or ~80 ms if the CPU is cold (due to Turbo Boost). | |
| // How it works: Start by generating a list of losing states -- states where the | |
| // game can end in one turn. Generate a new list of states by running the game |
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
| /* | |
| Three people are playing the following betting game. | |
| Every five minutes, a turn takes place in which a random player rests and the other two bet | |
| against one another with all of their money. | |
| The player with the smaller amount of money always wins, | |
| doubling his money by taking it from the loser. | |
| For example, if the initial amounts of money are 1, 4, and 6, | |
| then the result of the first turn can be either | |
| 2,3,6 (1 wins against 4); | |
| 1,8,2 (4 wins against 6); or |
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
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| "time" | |
| ) | |
| /* | |
| Three people are playing the following betting game. |
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
| task deployDebug(type: Exec, dependsOn: 'app:installDebug') { | |
| def rootDir = project.rootDir | |
| def localProperties = new File(rootDir, "local.properties") | |
| if (localProperties.exists()) { | |
| Properties properties = new Properties() | |
| localProperties.withInputStream { | |
| inputStream -> properties.load(inputStream) | |
| } | |
| def sdkDir = properties.getProperty('sdk.dir') | |
| def adb = "$sdkDir/platform-tools/adb" |
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
| # coding: utf8 | |
| import sys, urllib2 | |
| import socks | |
| from sockshandler import SocksiPyHandler | |
| from urlparse import urlparse | |
| if len(sys.argv) < 2: | |
| print 'Usage: python %s [url]' % sys.argv[0] | |
| exit() |
Erlang only has a few primitives that you need to worry about. Here they are below with corresponding Elixir examples.
integer: Erlang:123, Elixir:123float: Erlang:123.5, Elixir:123.5atom: Erlang:hello, Elixir::hellobinary: Erlang:<<"hello">>or<<10,20>>, Elixir:"hello"or<<10,20>>
So I've come across a nice, little elixir slackbot (if you've googled it you've seen it: https://github.com/BlakeWilliams/Elixir-Slack)
It seems to do everything I want in a slack bot except botkit's hears functionality. So here is a quick draft to do just that:
def hears(message, slack) do
to_hear = [
%{regex: ~r/^hello.*/i, cb: fn msg, slack -> send_message("Why hello", message.channel, slack) end},
%{regex: ~r/^sup.*/i, cb: fn msg, slack -> send_message("Not much yo", message.channel, slack) end},
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
| Definitions. | |
| WS = ([\000-\s]|%.*) | |
| T_VAR = [A-Za-z\.\-] | |
| Rules. | |
| or : {token,{'T_OR',TokenLine,list_to_atom(TokenChars)}}. | |
| and : {token,{'T_AND',TokenLine,list_to_atom(TokenChars)}}. | |
| {T_VAR}+ : {token,{'T_VAR',TokenLine,TokenChars}}. | |
| [()] : {token,{list_to_atom(TokenChars),TokenLine}}. |