This file contains hidden or 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
eval "return #redis.pcall('keys', 'prefix*')" 0 |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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 net.fehmicansaglam.minheap; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
@SuppressWarnings("unused") | |
public class MinHeap<K, V extends Comparable<V>, T extends MinHeap.Item<K, V>> { |
This file contains hidden or 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
val numbers = readLine().split(" ").map(_.toInt) // an array of numbers | |
val leftSums = numbers.scan(0)(_ + _).init // calculate cumulative sums from left | |
// search from right to find the same sum from left | |
var sum = 0 | |
val result = numbers.zipWithIndex.reverse.find { case (number, index) => | |
if (sum == leftSums(index)) true | |
else { | |
sum = sum + number | |
false |
This file contains hidden or 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
Step by step tutorial, the UX, and the worksheet are great. | |
(Although the worksheet did not run for some of the lessons on my Chrome, Ubuntu 14.04) |
This file contains hidden or 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
object Bilye extends App { | |
val onbellek = collection.mutable.Map[(Int, Int), Boolean]() | |
def onbellekliSpragueGrundy(p: Int, q: Int): Boolean = { | |
onbellek.getOrElseUpdate((p, q), spragueGrundy(p, q)) | |
} | |
def spragueGrundy(p: Int, q: Int) = { | |
if (p == 0) true |
This file contains hidden or 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
@Catch | |
static void exception(Throwable t) { | |
// Hatayı logla | |
Logger.error(ExceptionUtils.getStackTrace(t)); | |
// Dönüş mesajını oluştur | |
Throwable cause = t.getCause(); | |
String message = null; | |
if (cause != null && cause instanceof ConstraintViolationException) { | |
message = "constraint violation"; |
This file contains hidden or 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 controllers; | |
import static controllers.result.CustomJsonResult.renderCustomJson; | |
import java.util.Arrays; | |
import java.util.List; | |
import play.mvc.Controller; | |
public class Application extends Controller { |
This file contains hidden or 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 static ListenableFuture<Response> readFile(final String documentUuid, | |
final OutputStream os) { | |
final String requestUrl = ...; | |
try { | |
return new AsyncHttpClient().prepareGet(requestUrl) | |
.addQueryParameter("documentUuid", documentUuid) | |
.execute(new AsyncStreamHandler(os, documentUuid)); | |
} catch (final IOException e) { | |
throw new UnexpectedException(e); |
This file contains hidden or 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
Gson gson = new GsonBuilder().setPrettyPrinting().create(); | |
JsonParser jp = new JsonParser(); | |
JsonElement je = jp.parse(uglyJSONString); | |
String prettyJsonString = gson.toJson(je); |
NewerOlder