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
// If we have a Person class like this... | |
case class Person(firstName : String, lastName : String) | |
// ... and we want to use pattern matching to ensure | |
// an object is a Person with lastName "Jones" before | |
// send it to someFunction, we could do something like | |
// this: | |
someObject match { |
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
#include <iostream> | |
#include <curl/curl.h> | |
#include <math.h> | |
#include <vector> | |
#include <future> | |
#include <boost/format.hpp> | |
#define logbase(a, b) (log(a)/log(b)) | |
using namespace std; |
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
# Ignore dot-files, except the .gitignore file. | |
.* | |
!.gitignore | |
# (All rules from CSharp.gitignore) |
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
public class Thing | |
{ | |
public long ThingId { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } | |
} |
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
public virtual IEnumerable<Commit> GetFromTo(DateTime start, DateTime end) | |
{ | |
this.ThrowWhenDisposed(); | |
Logger.Debug(Resources.GettingAllCommitsFromToTime, start, end); | |
var selectedCommitIds = this.stamps.Where(x => x.Value >= start && x.Value < end).Select(x => x.Key); | |
var firstCommitId = selectedCommitIds.FirstOrDefault(); | |
var lastCommitId = selectedCommitIds.LastOrDefault(); | |
if (lastCommitId == Guid.Empty && lastCommitId == Guid.Empty) |
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
# gitlab 5.2.0 create user | |
# rake create_user["[email protected]","johndoe","John Doe"] RAILS_ENV=production | |
desc "Create new user" | |
task :create_user, [:email, :username, :name] => :environment do |t, args| | |
puts "creating user '" + args.username + "' ('" + args.name + "') with email '" + args.email + "'" | |
@user = User.new({ email: args.email, name: args.name, username: args.username, force_random_password: true, projects_limit: 10 }, as: :admin) | |
if @user.save | |
puts "success" | |
else |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
) | |
func main() { | |
syslog, err := os.Open("/var/log/system.log") |
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
defmodule State.Counter do | |
use GenServer | |
def start_link(opts \\ []) do | |
GenServer.start_link(__MODULE__, :ok, opts) | |
end | |
## Client API | |
@doc "Gets the counter's current value." |
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
defmodule BinaryConcat do | |
def run do | |
data = | |
<<65, 32, 119, 97>> <> | |
<<114, 110, 105, 110>> # <- binary concatenation operator missing here | |
<<103, 32, 112, 101>> <> | |
<<114, 104, 97, 112, 115, 63>> | |
IO.puts <<data :: binary>> | |
end |
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
(require '[clojure.core.typed :as t]) | |
; This seem to work nicely | |
(t/cf (identity 1)) ;=> [(t/Val 123) {:then tt, :else ff}] | |
; And this | |
(t/cf pmap) ;=> (All [c a b ...] (t/IFn [[a b ... b -> c] (t/NonEmptySeqable a) (t/NonEmptySeqable b) ... b -> (t/NonEmptyASeq c)] [[a b ... b -> c] (t/U nil (Seqable a)) (t/U nil (Seqable b)) ... b -> (t/ASeq c)])) | |
; But when I combine the two... | |
(t/cf (pmap identity [1 2 3]) ;=> Type Error (/tmp/form-init5174330476817989076.clj:1:7) Polymorphic function pmap could not be applied to arguments: |
OlderNewer