Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com

Francois-Guillaume Ribreau FGRibreau

✍️
writing "#NoBullshit Tech-Lead" book https://getnobullshit.com
View GitHub Profile
View exception.sh
Exception in thread "main" java.io.IOException: java.lang.reflect.UndeclaredThrowableException
at org.apache.cassandra.tools.NodeProbe.forceRepairAsync(NodeProbe.java:230)
at org.apache.cassandra.tools.NodeCmd.optionalKSandCFs(NodeCmd.java:1502)
at org.apache.cassandra.tools.NodeCmd.main(NodeCmd.java:1221)
Caused by: java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy0.forceRepairAsync(Unknown Source)
at org.apache.cassandra.tools.RepairRunner.repairAndWait(NodeProbe.java:1019)
at org.apache.cassandra.tools.NodeProbe.forceRepairAsync(NodeProbe.java:225)
... 2 more
Caused by: javax.management.ReflectionException: Signature mismatch for operation forceRepairAsync: (java.lang.String, boolean, java.util.Collection, boolean, [Ljava.lang.String;) should be (java.lang.String, boolean, boolean, boolean, [Ljava.lang.String;)
View cassandra.sh
# On host 1 (from where "nodetool -h somewhereelse" was run)
ls -ls /usr/share/cassandra/*.jar
3304 -rw-r--r-- 1 cassandra cassandra 3380834 Jan 13 21:12 /usr/share/cassandra/apache-cassandra-2.0.4.jar
0 lrwxrwxrwx 1 cassandra cassandra 26 Jan 13 21:12 /usr/share/cassandra/apache-cassandra.jar -> apache-cassandra-2.0.4.jar
1816 -rw-r--r-- 1 cassandra cassandra 1855571 Jan 13 21:12 /usr/share/cassandra/apache-cassandra-thrift-2.0.4.jar
80 -rw-r--r-- 1 cassandra cassandra 78965 Jan 13 21:12 /usr/share/cassandra/stress.jar
# On host 2 (somewhereelse)
ls -ls /usr/share/cassandra/*.jar
3192 -rw-r--r-- 1 cassandra cassandra 3265362 Sep 5 20:26 /usr/share/cassandra/apache-cassandra-2.0.0.jar
View 2048game.js
var a=new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
a.won=!0;
a.score=32768;
a.actuate();
@FGRibreau
FGRibreau / vote.js
Created Jun 28, 2014
How to automatically vote on VoicePolls -__- #ScriptKiddieLevel
View vote.js
/**
* How to automatically vote on VoicePolls -__- #ScriptKiddieLevel
*
* Guys, you should really check — at least — for IPs and — at least — put a rate-limit on API calls.
*
* Usage :
* $ npm install async request
* $ node vote.js
*/
@FGRibreau
FGRibreau / regex.js
Last active Aug 29, 2015
Regex to hang on V8 engine (Chrome/NodeJS)
View regex.js
// The following script will hang on V8 regex engine. (It works fine on Safari Mac).
// Regex was taken from https://gist.github.com/gruber/249502
"http://www.ghislainproulx.net/Blog/2014/09/contributing-to-a-github-open-source-project-(from-a-visual-studio-developer-perspective)".replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi, function(url){
// this will never be executed on Chrome/Node
console.log(url);
});
// Checkout your CPU consumption !
@FGRibreau
FGRibreau / student_question.js
Last active Aug 29, 2015
student_question.js
View student_question.js
'use strict';
/**
$node perfs.js
___________________________________________________[Bench] Generating table (size=1600000) took: 593ms
sum=816028274.8700228
avg=510.01767179376424
___________________________________________________[Bench] Calculating sum took: 78ms
___________________________________________________[Bench] Sort users by rank DESC took: 2702ms
Best score user(id=1322940, score=1010, rank=0)
View comment.md
function getBackgroundColor (user) {  
  var m = user.picture.match(/avatar\/(\w+|$)/);
  if (m && m[1]) {
    return '#' + m[1].substring(0,6);
  }
}

Bonne idée ! Quelques remarques cependant :

View problem.sh
$ cat package.json | grep "test"
"test": "mocha -t 5000 -R spec **/*.test.js~node_modules/*",
$ npm test
> mocha -t 5000 -R spec **/*.test.js~node_modules/*
/www/statwarn-monitoring-api/node_modules/mocha/lib/utils.js:494
if (!files.length) throw new Error("cannot resolve path (or pattern) '"
^
Error: cannot resolve path (or pattern) '**/*.test.js~node_modules/*'
View solution.sh
$ cat package.json | grep "test"
"test": "zsh -c 'setopt extended_glob;mocha -t 5000 -R spec **/*.test.js~node_modules/*; zsh -i'",
$ npm test
> zsh -c 'setopt extended_glob;mocha -t 5000 -R spec **/*.test.js~node_modules/*; zsh -i'
(... tests start ...)
@FGRibreau
FGRibreau / SingletonTester-issue.js
Created Feb 8, 2015
Addy Osmani - Essential JavaScript Design Patterns - Singleton issue
View SingletonTester-issue.js
//This "SingletonTester" is not a valid Singleton because:
var InnerConstructor = SingletonTester.getInstance({
pointX: 5
}).constructor;
console.log(new InnerConstructor() !== new InnerConstructor()); // true