Skip to content

Instantly share code, notes, and snippets.

View rocel's full-sized avatar

Damien Chaillou rocel

  • WHM
  • Niteroi, Brazil / Nantes, France
  • X @dragda
View GitHub Profile
@rocel
rocel / program.py
Created September 4, 2023 02:29 — forked from Yatoom/program.py
Minion translator
from words import words
minionese_to_english = {v: k for k, v in words.items()}
def translate(sentence, minionese=False):
dictionary = words if not minionese else minionese_to_english
result = ""
for word in sentence.split(" "):
if word in dictionary.keys():
@rocel
rocel / requery.py
Created August 2, 2019 12:58 — forked from lloydw/requery.py
Simple query object for combining multiple redash queries
#
# Simple query object for combining multiple redash queries
#
# Example usage:
# Find all users who have logged in in the last 8 weeks who have sent an email by analysing the logstash logs
# Then group the results by the week they signed up on and their emailed yes/no status
#
# import requery
# userQuery = 'SELECT * FROM user WHERE lastSeen > DATE_SUB(NOW(), INTERVAL 8 WEEK)'
# emailQuery = '{ "index" : "logstash-*", "query": { "query_string": { "query": "action:sendEmail" } }, "size" : 1000 }
@rocel
rocel / SlackService.scala
Created January 4, 2019 18:05 — forked from ignasi35/SlackService.scala
A PoC client for Slack's "Custom Integrations" implemented as a Lagom Service.
package com.example.hello.api
import akka.NotUsed
import com.example.hello.api.SlackCustomIntegration.Message
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.Service._
import com.lightbend.lagom.scaladsl.api.transport.Method
import play.api.libs.json._
import play.api.libs.functional.syntax._
@rocel
rocel / Aircrack Commands
Created August 8, 2018 03:22 — forked from victorreyesh/Aircrack Commands
Cracking WPA2 / WEP Wifi / Aircrack 10 seconds guide. For Mac OSX
//Install Macports.
//Install aircrack-ng:
sudo port install aircrack-ng
//Install the latest Xcode, with the Command Line Tools.
//Create the following symlink:
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
//Figure out which channel you need to sniff:
sudo airport -s
sudo airport en1 sniff [CHANNEL]
@rocel
rocel / kakfa-oneway.java
Created July 12, 2018 19:56 — forked from codefromthecrypt/kakfa-oneway.java
Kafka one-way with Brave
/**
* This is an example of a one-way or "messaging span", which is possible by use of the {@link
* Span#flush()} operator.
*
* <p>Note that this uses a span as a kafka key, not because it is recommended, rather as it is
* convenient for demonstration, since kafka doesn't have message properties.
*
* <p>See https://github.com/openzipkin/zipkin/issues/1243
*/
public class KafkaExampleIT {
@rocel
rocel / flatten.java
Created May 23, 2018 23:32 — forked from ebuildy/flatten.java
Flatten Spark data frame fields structure, via SQL in Java
class Toto
{
public void Main()
{
final DataFrame source = GetDataFrame();
final String querySelectSQL = flattenSchema(source.schema(), null);
source.registerTempTable("source");
final DataFrame flattenData = sqlContext.sql("SELECT " + querySelectSQL + " FROM source")
@rocel
rocel / BackgroundService.java
Created May 13, 2017 18:15 — forked from gfreivasc/BackgroundService.java
A BackgroundService class for Android
package com.gabrielfv.android.engine;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
@rocel
rocel / headless.md
Created April 12, 2017 20:14 — forked from addyosmani/headless.md
So, you want to run Chrome headless.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

You can use chrome --headless on Linux as of M57 but note you'll need to build the binaries yourself for now.

The metabug for adding headless mode to Chromium is over here.

angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}
}else{
# NPM CheatSheet.
# Super easy intall: npm comes with node now.
# To create your own npm package: https://www.npmjs.org/doc/misc/npm-developers.html
# More: https://www.npmjs.org/doc/
# 1. NPM Command Lines.
# Local mode is the default.
# Use --global or -g on any command to operate in global mode instead.