Skip to content

Instantly share code, notes, and snippets.

@shunjikonishi
shunjikonishi / github.json
Created August 28, 2017 08:44
GitHub hook request
{
"ref": "refs/heads/master",
"before": "2a2496f5295e6114b17360c2f33e1ab57ba3ab78",
"after": "1970003cb79b1c868bff1c81136dac5d5722a8f4",
"created": false,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/givery-technology/codeprep-contents-new/compare/2a2496f5295e...1970003cb79b",
"commits": [

Usecase

  • There are too many items.
    • e.g. log output
    • It migght be more than million.
  • Need to store latest 1000 items.

Solution

We can implement with simple array

"use strict";
var React = require("react");
var Link = require('react-router').Link;
var Tabs = React.createClass({
render: function() {
return (
<div>
<ul>
module.exports = function (grunt) {
'use strict';
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var proxyOptionsLocal = {
var assert = require("chai").assert;
var codecheck = require("codecheck");
var expected = [];
for (var i=1; i<= 100; i++ ) {
if(i % 15 == 0) expected.push("FizzBuzz");
else if (i % 5 == 0) expected.push("Buzz");
else if (i % 3 == 0) expected.push("Fizz");
else expected.push("" + i);
}
SELECT
c.id,
count(cr.id) as count
FROM challenges c
LEFT OUTER JOIN exam_challenges ec ON (c.id = ec.challenge_id)
INNER JOIN exams e ON (ec.exam_id = e.id)
LEFT OUTER JOIN exam_delivers ed ON (ed.exam_id = e.id)
LEFT OUTER JOIN challenge_results cr ON (c.id = cr.challenge_id AND cr.deliver_id = ed.id)
WHERE c.user_id in (1)
GROUP BY c.id
@shunjikonishi
shunjikonishi / QueryDSL.scala
Last active August 29, 2015 14:23
Skinny group by sample
val c = Challenge.syntax("c")
val cr = ChallengeResult.syntax("cr")
val list = withSQL {
select(
c.result.*,
sqls"count(cr.id) as count"
).from(Challenge as c)
.leftJoin(ChallengeResult as cr)
.on(c.id, cr.challengeId)
.where(buildCondition(user.id, publicOnly))
@shunjikonishi
shunjikonishi / Test.scala
Last active August 29, 2015 14:22
問5回答 40分くらい
// http://www.softantenna.com/wp/software/5-programming-problems/
// Problem 5
case class Expr(str: String, ret: Int) {
def plus(n: Int) = Expr(str + " + " + n, ret + n)
def minus(n: Int) = Expr(str + " - " + n, ret - n)
def concat(n: Int) = {
val next = last match {
case 0 => ret * 10 + n
case x if (x < 0) => ret - x + (x * 10) - n
case x if (x > 0) => ret - x + (x * 10) + n
@shunjikonishi
shunjikonishi / implicitDef.scala
Created May 13, 2015 10:58
Simple example of implicit def.(REPL)
scala> val a = "Jack"
a: String = Jack
scala> a.hello
<console>:9: error: value hello is not a member of String
a.hello
^
scala> class B(s: String) {
| def hello = "Hello " + s
@shunjikonishi
shunjikonishi / sql-fixtures.js
Created April 24, 2015 04:21
node-sql-fixtures #28
"use strict";
/*
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NULL,
github_username VARCHAR(255) NULL,
password VARCHAR(255) NULL,
image_url VARCHAR(255) NULL,