Skip to content

Instantly share code, notes, and snippets.

View simonewebdesign's full-sized avatar
🇺🇦
💙 💛

Simone Vittori simonewebdesign

🇺🇦
💙 💛
View GitHub Profile
@simonewebdesign
simonewebdesign / sum.md
Created November 7, 2016 11:55
Ruby's sum method
@simonewebdesign
simonewebdesign / install-quake3.sh
Last active November 14, 2023 19:25
Install Quake 3: Arena on a mac
#!/bin/bash
# Install Quake 3: Arena on a mac
# Copyright (c) 2016 simonewebdesign
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
@simonewebdesign
simonewebdesign / first-commit.js
Last active October 26, 2016 12:27 — forked from JamesWP/Get the first commit url.js
A snippet using GitHub's public API to get the URL and SHA of the first commit for a given repo. Works also for private repos, but you need a token.
// A snippet using GitHub's public API to get
// the URL and SHA of the first commit for a given repo
function openFirstCommit(userorg, repo, authToken) {
var opts = authToken ?
{ headers: new Headers({
'Authorization': 'token ' + authToken
})
} : {}
@simonewebdesign
simonewebdesign / release.sh
Created October 26, 2016 10:49
Create a new release on GitHub by reading from a VERSION file.
#!/bin/bash
##
# This script creates a new release by reading from VERSION file.
##
set -e # Exit on error
set +x # Debug mode (-x on, +x off)
version="$(cat VERSION)"
@simonewebdesign
simonewebdesign / FilterSpaces.elm
Created October 5, 2016 14:08
Filter spaces in Elm 0.17
import Html exposing (text)
import String
main =
(String.filter (not << isSpace) "1023 49 85")
|> String.toInt
|> toString
|> text
@doc """
Returns the sum of all elements.
Raises `ArithmeticError` if `enumerable` contains a non-numeric value.
## Examples
iex> Enum.sum([1, 2, 3])
6
def to_sentence(list) do
list |> Enum.reverse |> Enum.reduce(fn(b,c) -> b <> ", " <> c end)
end
to_sentence ["foo", "bar", "baz"] == "foo, bar, baz"
# other cases, using Enum.map_join:
Enum.map_join(languages, ", ", fn(_) -> "_" end)
@simonewebdesign
simonewebdesign / Decoder.elm
Created July 25, 2016 11:04
An example of Json.Decoder (Result a b) in Elm
decodeSubmittedReportPayload : Json.Decoder SubmittedReportPayload
decodeSubmittedReportPayload =
Json.object1
SubmittedReportPayload
("report" := decodeReportCredentials)
decodeInvalidReportPayload : Json.Decoder InvalidReportPayload
decodeInvalidReportPayload =
Json.object1
@simonewebdesign
simonewebdesign / Dict.elm
Created July 15, 2016 16:39
Elm Dict visual representation
[ ( "path", 123 )
, ( "value", Nothing )
]
@simonewebdesign
simonewebdesign / positiveSum.hs
Last active June 16, 2016 12:13
Sum of positives in Haskell
positiveSum :: [Int] -> Int
positiveSum a =
let
positives = filter (>0) a
in
foldl (+) 0 positives
# …OR…
positiveSum :: [Int] -> Int