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
def factors(n): | |
app = [n] if n != 1 else [] | |
ans = set(chain(app, *((i, n//i) for i in range(2, int(sqrt(n) + 1)) | |
if not n % i))) | |
return ans |
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
import Control.Monad.ST | |
import Control.Monad | |
import Data.Array | |
import Data.Array.ST | |
import Data.List (elemIndex) | |
import Data.Maybe (fromMaybe) | |
newSTArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e) | |
newSTArray = newArray |
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
{-# LANGUAGE ScopedTypeVariables #-} | |
module BST where | |
import Test.QuickCheck | |
import Control.Monad | |
import Control.Applicative | |
data BST a = Empty | |
| Node {value :: a, left :: BST a, right :: BST a} |
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
class Greeting extends SActivity { | |
val LOCATION_DEFAULT = "Location not available." | |
override def onCreate(savedInstanceState: Bundle) { | |
super.onCreate(savedInstanceState) | |
var latText: STextView = null | |
var lonText: STextView = null | |
contentView = new SVerticalLayout { | |
STextView(s"${R.string.prompt.r2String}! ${getIntent.getStringExtra("name")}") textSize 75.dip | |
latText = STextView(LOCATION_DEFAULT) textSize 50.dip | |
lonText = STextView(LOCATION_DEFAULT) textSize 50.dip |
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
/usr/lib/jvm/java-8-oracle/bin/java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -Didea.launcher.port=7538 -Didea.launcher.bin.path=/home/patrick/hacking/java/intellij-idea/bin -Dfile.encoding=UTF-8 -classpath /home/patrick/.IdeaIC14/config/plugins/Scala/launcher/sbt-launch.jar:/home/patrick/hacking/java/intellij-idea/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain xsbt.boot.Boot android:package | |
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0 | |
[info] Loading project definition from /home/patrick/hacking/mobile/hello-scaloid-sbt/project | |
[info] Set current project to hello-scaloid-sbt (in build file:/home/patrick/hacking/mobile/hello-scaloid-sbt/) | |
[info] Processing resources | |
ProGuard, version 5.1 | |
ProGuard is released under the GNU General Public License. You therefore | |
must ensure that programs that link to it (android, ...) | |
carry the GNU General Public License as well. Alternatively, you can | |
apply for an excepti |
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
DROP VIEW OneHop; | |
DROP VIEW TwoHop; | |
DROP VIEW ThreeHop; | |
CREATE VIEW OneHop AS | |
SELECT dst as airportCode | |
FROM Flights | |
WHERE src="PDX"; | |
SELECT name FROM OneHop NATURAL JOIN Airports; |
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
➜ p3 git:(master) ✗ ./chidb 1table-1index-1pageeach.cdb | |
chidb> explain select code from numbers where altcode > 5; | |
addr opcode p1 p2 p3 p4 | |
---------- ---------- ---------- ---------- ---------- ---------- | |
0 Integer 2 0 0 | |
1 OpenRead 0 0 3 | |
2 Integer 5 1 0 | |
3 Integer 3 2 0 | |
4 OpenRead 1 2 2 |
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
should_start = (not partial_start) or (dt != gnip_start) | |
should_end = (not partial_end) or (dt != gnip_end) | |
if should_start and should_end: | |
acc[str(d)] = str(v) |
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
should_start = (not partial_start) or (dt != gnip_start) | |
should_end = (not partial_end) or (dt != gnip_end) | |
should_something = partial_start and partial_end | |
if should_something and should_start and should_end: | |
acc[(str(d))] = str(v) |
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 <stdio.h> | |
#ifdef BE_QUIET | |
#define P_TYPE(x, type) | |
#else | |
#define P_TYPE(x, type) printf("%s @ (%s:%d): %s " type "\n", __func__, __FILE__, __LINE__, #x, x) | |
#endif | |
#define PI(x) P_TYPE(x, "%i") | |
#define PS(x) P_TYPE(x, "%s") |