Skip to content

Instantly share code, notes, and snippets.

View blackdev1l's full-sized avatar

Cristian Achille blackdev1l

View GitHub Profile
Optional<File[]> files = Optional.ofNullable(new File(staticFolder).listFiles());
return files.map(logos -> Arrays.stream(logos)
.filter(file -> file.getName().matches(".+(png|jpg|gif)"))
.findFirst()
.map(filename -> String.format("%s/%s/logo/%s", staticUrl, division, filename))
.orElse(""))
.orElse("");
Optional<File[]> files = Optional.ofNullable(new File(staticFolder).listFiles());
return files.map(logos -> Arrays.stream(logos)
.filter(file -> file.getName().matches(".+(png|jpg|gif)"))
.findFirst()
.map(filename -> String.format("%s/%s/logo/%s", staticUrl, division, filename))
.orElse(""))
.orElse("");
@blackdev1l
blackdev1l / unset.go
Created January 26, 2016 13:35
tars merda
package main
import (
"bufio"
"fmt"
"net/http"
"os"
)
const APIURL = "https://api.telegram.org/bot"
func store(text string, c redis.Conn) {
text = strings.ToLower(text)
splitted := strings.Split(text, " ")
fmt.Println(len(splitted))
for k, v := range splitted {
if k < len(splitted) {
fmt.Printf("%s -> %s\n", splitted[k], splitted[k+1])
c.Do("SADD", v, splitted[k+1])
func (r *Runner) getJSON() {
thread := strconv.Itoa(r.thread)
jsonURL := "http://a.4cdn.org/" + r.board + "/thread/" + thread + ".json"
resp, err := http.Get(jsonURL)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
@blackdev1l
blackdev1l / gist:139fe5af6868db9daa7e
Created May 5, 2015 07:54
AsyncTask for GET request and parse on a custom adapter
private class CallAPI extends AsyncTask<String, String, JSONArray> {
JSONArray jArray;
@Override
protected JSONArray doInBackground(String... urls) {
try {
URL url = new URL(getString(R.string.api_url));
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.setRequestMethod("GET");
### Keybase proof
I hereby claim:
* I am blackdev1l on github.
* I am blackdev1l (https://keybase.io/blackdev1l) on keybase.
* I have a public key whose fingerprint is 3753 7A16 5254 D650 223D 7F07 8216 1FD3 4C14 2D96
To claim this, I am signing this object: