aw
– a word (includes surrounding white space)iw
– inner word (does not include surrounding white space)
as
- a sentence
############################## | |
##Exercise: ModulesAndFunctions-6 | |
defmodule Chop do | |
def guess(actual, lo..hi) when (lo <= hi) and (actual in lo..hi) do | |
current = guessing(lo, hi) | |
IO.puts "Is it #{current}" | |
guess(current, actual, lo..hi) | |
end | |
defp guess(value, actual, _) when value == actual, do: IO.puts value |
sudo killall -HUP mDNSResponder |
def flatten(list), do: flatten(list, []) |> Enum.reverse | |
def flatten([h | t], acc) when h == [], do: flatten(t, acc) | |
def flatten([h | t], acc) when is_list(h), do: flatten(t, flatten(h, acc)) | |
def flatten([h | t], acc), do: flatten(t, [h | acc]) | |
def flatten([], acc), do: acc |
# equal jsons | |
json1 = '{"polygons":[{"type":"rectangle","vertices":[{"x":1621.5,"y":1079.5},{"x":2674,"y":1079.5},{"x":2674,"y":2528},{"x":1621.5,"y":2528}],"category":"name"}]}' | |
json2 = '{"polygons":[{"type":"rectangle","category":"name","vertices":[{"x":1621.5,"y":1079.5},{"x":2674,"y":1079.5},{"x":2674,"y":2528},{"x":1621.5,"y":2528}]}]}' | |
rez1 = JSON.parse(json1) | |
rez2 = JSON.parse(json2) | |
rez1 == rez2 # true | |
class FlashMessages extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { messages: props.messages }; | |
} | |
render () { | |
return( | |
<div> |
#!/usr/bin/env ruby | |
# | |
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156) | |
# | |
# ## Advisory | |
# | |
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion | |
# | |
# ## Caveats | |
# |
#!/bin/sh | |
crystal tool format --check &> /dev/null | |
ret_code=$? | |
if [ 0 -ne $ret_code ]; then | |
crystal tool format | |
echo "Files formatted. Please review results and commit ;)" | |
exit $ret_code | |
else |
class Object | |
macro inherited | |
@@methods = {} of String => Proc({{@type}}, Nil) | |
macro method_added(method) | |
\{% if method.visibility == :public %} | |
%key = \{{ method.name.stringify }} | |
@@methods[%key] = ->(obj : \{{@type}}) { | |
obj.\{{ method.name }}() | |
nil |
require "http/client" | |
require "json" | |
module GithubAPI | |
API_URL = "https://api.github.com" | |
class Repo | |
JSON.mapping( | |
name: String, | |
html_url: String, |