Skip to content

Instantly share code, notes, and snippets.

:shipit:
aha

DiveInto

:shipit:
aha
Block or report user

Report or block DiveInto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DiveInto
DiveInto / Dockerfile
Last active Feb 20, 2020
for kubebuilder
View Dockerfile
# https://github.com/kubernetes-sigs/kubebuilder/blob/master/build/thirdparty/linux/Dockerfile
# https://github.com/kubernetes-sigs/kubebuilder/blob/2ea629ba2ebb791aefce579a1e6106caa084df8f/build/thirdparty/linux/Dockerfile
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@DiveInto
DiveInto / permutations.scala
Created Sep 15, 2013
compute all permutations of a string
View permutations.scala
object per extends App{
def permutations(str: String):List[String] = {
if(str.size == 0)
List("")
else{
val res = {
for{c <- str
per <- permutations(str.replaceFirst(c.toString, ""))
}yield c + per
}
@DiveInto
DiveInto / cache-recursive.scala
Last active Dec 22, 2015
I'll speak generally, then. About recursive functions using a cache: they must return, in addition of the result, an upated cache.
View cache-recursive.scala
/**
* https://class.coursera.org/progfun-002/forum/thread?thread_id=1175#comment-3124
**/
object Main extends App {
class MemoStringFunction[T](f: String => T, base: String) {
private lazy val v = f(base)
private lazy val ts = (for {
tx <- 'a' to 'z'
} yield (tx, new MemoStringFunction(f, base + tx))).toMap
@DiveInto
DiveInto / combination.scala
Last active Dec 22, 2015
Functional Programming Principles in Scala week-6 Anagram code snippet
View combination.scala
/**
计算全部子集
Input: List( ('a', 2), ('b', 2))
Output:
Nil
List(('a', 1))
List(('a', 2))
View akka.scala
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.tutorial.first.scala
import akka.actor._
import akka.routing.RoundRobinRouter
import akka.util.Duration
import akka.util.duration._
View producers.scala
package examples.actors
import scala.actors.Actor
import scala.actors.Actor._
abstract class Producer[T] {
/** A signal that the next value should be produced. */
private val Next = new Object
View MLeaks.java
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
public class MLeaks {
static byte[] m = new byte[1024 * 1024];
static ThreadLocal<MLeaks> tLocal = new ThreadLocal<MLeaks>(){
@Override
protected MLeaks initialValue()
{
View MongoDB-Error-Codes.txt
checkout:
https://github.com/mongodb/mongo/blob/master/docs/errors.md
@DiveInto
DiveInto / install-java.sh
Created Jun 19, 2012
install sun-java on ubuntu
View install-java.sh
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:sun-java-community-team/sun-java6
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
$ sudo apt-get remove openjdk-6-jdk --purge -y
$ sudo apt-get autoremove
sudo update-java-alternatives -s java-6-sun
View ruby.rb
#== Never use for, unless you know exactly why. Most of the time iterators should be used instead. for is implemented in terms of each (so you're adding a level of indirection), but with a twist - for doesn't introduce a new scope (unlike each) and variables defined in its block will be visible outside it.
arr = [1, 2, 3]
# bad
for elem in arr do
puts elem
end
# good
arr.each { |elem| puts elem }
You can’t perform that action at this time.