Skip to content

Instantly share code, notes, and snippets.

View btipling's full-sized avatar

Bjorn btipling

View GitHub Profile
@btipling
btipling / foo.json
Last active June 2, 2020 19:53
Just some JSON to parse.
{
"foo": 3,
"bar": 10
}
Compiling korasho v0.1.0 (file:///Users/bjorn/projects/korasho)
src/connect.rs:32:45: 32:78 error: use of undeclared type name `std::Result` [E0412]
src/connect.rs:32 pub fn connect(server: ::config::Server) -> ::std::Result<Connection, String> {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/connect.rs:32:45: 32:78 help: run `rustc --explain E0412` to see a detailed explanation
error: aborting due to previous error
Could not compile `korasho`.
Compiling korasho v0.1.0 (file:///Users/bjorn/projects/korasho)
<std macros>:1:33: 1:58 error: invalid reference to argument `0` (no arguments given)
<std macros>:1 ( $ fmt : expr ) => ( print ! ( concat ! ( $ fmt , "\n" ) ) ) ; (
^~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:33: 1:58 note: in this expansion of concat!
<std macros>:2:25: 2:56 note: in this expansion of format_args!
<std macros>:1:23: 1:60 note: in this expansion of print! (defined in <std macros>)
src/main.rs:143:5: 143:29 note: in this expansion of println! (defined in <std macros>)
error: aborting due to previous error
Could not compile `korasho`.
@btipling
btipling / connect.rs
Created December 27, 2015 23:57 — forked from mathieulegrand/connect.rs
simple connect to server:443 in Rust
// Rust 0.10-pre (Tue Mar 18, 2014)
// $ rustc -L rust-openssl/build/ -L rust-toml/lib doing.rs
// assuming https://github.com/sfackler/rust-openssl is cloned and compiled,
// and https://github.com/mneumann/rust-tom is cloned and compiled
#[feature(macro_rules)];
#[allow(deprecated_owned_vector)];
extern crate openssl;
extern crate serialize;
fn main() {
fn map<F, T, A>(option: Option<T>, f: F) -> Option<A> where F: FnOnce(T) -> A {
match option {
None => None,
Some(value) => Some(f(value)),
}
}
}
curl -vvv "http://50.168.68.186:3080/nphMotionJpeg?Resolution=640x480&Quality=Standard"
* Trying 50.168.68.186...
* Connected to 50.168.68.186 (50.168.68.186) port 3080 (#0)
> GET /nphMotionJpeg?Resolution=640x480&Quality=Standard HTTP/1.1
> Host: 50.168.68.186:3080
> User-Agent: curl/7.43.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
@btipling
btipling / hw-csi194.hs
Created September 29, 2015 20:21
1st solution to csi 194 hw1 probl
main = putStrLn "Hello, World!"
doubleSecondNum :: [Int] -> [Int]
doubleSecondNum numbers
| length numbers == 0 = numbers
| otherwise = reverse (map doubleEven (zip (reverse numbers) [0..]))
doubleEven :: (Int, Int) -> Int
doubleEven pair
| (succ (snd pair)) `mod` 2 == 0 = (fst pair) * 2
def find_best(telephone_number):
results = filter(lambda x : telephone_number.find(x) is not -1, ("001","001631","001800"))
current = ""
for res in results:
if len(res) > len(current):
current = res
return current
print(find_best("0016316420665"))
~ $ python
Python 2.7.10 (default, Jun 2 2015, 17:24:15)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> l = [1]
>>> d = {}
>>> d[l] = "foo"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
bash-3.2$ vim test
bash-3.2$ chmod +x test
bash-3.2$ ./test
moo
bash-3.2$ cat test
#!/bin/bash
echo "moo"