Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
👨🏻‍🍳 helping you cook better apps

Younes Jaaidi yjaaidi

💭
👨🏻‍🍳 helping you cook better apps
View GitHub Profile
@yjaaidi
yjaaidi / argument_parsing_inheritance.py
Created Feb 12, 2014
Python Argument Parsing Inheritance
View argument_parsing_inheritance.py
import argparse
import sys
class Command(object):
def __init__(self):
self._argument_parser = argparse.ArgumentParser()
def main(self, args):
self._main(self._argument_parser.parse_args(args))
@yjaaidi
yjaaidi / splunk-above-average-activity
Last active Oct 30, 2015
Splunk Search Query - Detect Above Average Activity Using Standard Deviation
View splunk-above-average-activity
tag=firewall action=deny
| stats count values(dst) by src
| eventstats avg(count) as avg_count
| eval standard_deviation=count/avg_count
| fields - count, avg_count
| search standard_deviation > 10
View named-parameters.js
// Generated by CoffeeScript 1.4.0
(function() {
var NamedParameters, exports;
NamedParameters = (function() {
var _assert, _clone;
function NamedParameters(m) {
this.map = _clone(m);
this.coerce_all = false;
@yjaaidi
yjaaidi / wt-typescript-contracts.ts
Last active Jun 8, 2016
TypeScript dynamic runtime contracts example
View wt-typescript-contracts.ts
import 'reflect-metadata';
let _contractDictMetadataKey = 'contractDict';
let ApplyContracts = () => {
return (target, key) => {
let originalMethod = target[key];
let contractDict = Reflect.getOwnMetadata(_contractDictMetadataKey, target, key);
@yjaaidi
yjaaidi / webpack-dynamic-file-name-resolution.js
Created Nov 13, 2016
Webpack Dynamic File Name Resolution
View webpack-dynamic-file-name-resolution.js
/*
* Webpack config
*/
/* Use file-loader for images. */
{
test: /\.(gif|ico|jpg|png|svg)$/,
loader: 'file'
}
@yjaaidi
yjaaidi / wt-dynamic-component-injector.js
Created Apr 27, 2017
Angular dynamic component injector
View wt-dynamic-component-injector.js
@Injectable()
export class ComponentInjector {
constructor(
private _injector: Injector,
private _applicationRef: ApplicationRef,
private _componentFactoryResolver: ComponentFactoryResolver) {
}
View reactive-store.ts
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { Observable } from 'rxjs/Observable';
export abstract class ReplayStore<T> {
private _isInitialized = false;
private _state: T;
private _state$: ReplaySubject<T>;
constructor() {
@yjaaidi
yjaaidi / splunk-most-request-resource-by-user
Last active Jul 9, 2017
Splunk Search Query - Most Request Resource By User
View splunk-most-request-resource-by-user
stats count by user fqdn
| eventstats sum(count) as count_by_user by user
| eval percent=count/count_by_user
| table user, fqdn, percent, count, count_by_user
| sort - percent
| search count_by_user > 100
@yjaaidi
yjaaidi / generate-cert.sh
Created Jul 10, 2017
Generate dev self-signed certificate
View generate-cert.sh
#!/usr/bin/env bash
# Generate private key and CSR.
openssl req -nodes -newkey rsa:2048 -keyout ssl/server.key -out ssl/server.csr -subj "//CN=devserver"
# Auto-signing.
#openssl req -x509 -sha256 -days 365 -key ssl/server.key -in ssl/server.csr -out ssl/server.pem
openssl x509 -req -days 365 -in ssl/server.csr -signkey ssl/server.key -out ssl/server.crt
# Removing CSR.
View rest-api-workflow.py
// Create an order.
POST /orders
request = {
title: 'TITLE',
description: 'DESCRIPTION'
}
response = {
id: 'ORDER_ID',
title: 'TITLE',