Skip to content

Instantly share code, notes, and snippets.

View charlenopires's full-sized avatar

Charleno Pires charlenopires

View GitHub Profile
@asarazan
asarazan / Original.dart
Created June 3, 2017 18:19 — forked from sethladd/Original.dart
Comparing Flutter to what it might look like in Kotlin, Dart.soon, and Dart.wishlist
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,
@depp
depp / problem.cpp
Last active December 21, 2021 19:04
A Faster Solution
// 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
@boyter
boyter / Puzzle.java
Last active October 15, 2021 07:36
Friday Quiz Solution
/*
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
@walesey
walesey / main.go
Last active October 10, 2019 02:03
Friday Quiz Solution
package main
import (
"fmt"
"math"
"time"
)
/*
Three people are playing the following betting game.
@android10
android10 / build.gradle
Last active August 29, 2023 14:31
Compile and launch android app from the command line.
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"
@Emory-M
Emory-M / m3u8dl.py
Last active April 8, 2023 05:38
Download m3u8 and merge ts file with python urllib2
# 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()
@drewkerrigan
drewkerrigan / README.md
Last active February 6, 2018 13:19
Erlang / Elixir in 5 Minutes or Less

Learning Erlang / Elixir Basics

Primitives

Erlang only has a few primitives that you need to worry about. Here they are below with corresponding Elixir examples.

  1. integer: Erlang: 123, Elixir: 123
  2. float: Erlang: 123.5, Elixir: 123.5
  3. atom: Erlang: hello, Elixir: :hello
  4. binary: Erlang: &lt;&lt;"hello"&gt;&gt; or &lt;&lt;10,20&gt;&gt;, Elixir: "hello" or &lt;&lt;10,20&gt;&gt;

Playing with elixir and slackbots!

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 -&gt; send_message("Not much yo", message.channel, slack) end},
@schleumer
schleumer / guardian_lexer.xrl
Last active June 5, 2016 04:01
Simple yecc and leex parser
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}}.
@addyosmani
addyosmani / pwas.md
Last active June 10, 2020 18:30
💄💋 Progressive Web Apps across popular frameworks that I have written or contributed significantly to

React HN (Universal rendering, Offline caching, optimisations)

React + Webpack application using the PRPL pattern