Skip to content

Instantly share code, notes, and snippets.

View yjaaidi's full-sized avatar
💭
👨🏻‍🍳 helping you cook better apps

Younes Jaaidi yjaaidi

💭
👨🏻‍🍳 helping you cook better apps
View GitHub Profile
@yjaaidi
yjaaidi / splunk-above-average-activity
Last active October 30, 2015 14:49
Splunk Search Query - Detect Above Average Activity Using Standard Deviation
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
@yjaaidi
yjaaidi / splunk-most-request-resource-by-user
Last active July 9, 2017 19:16
Splunk Search Query - 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 / argument_parsing_inheritance.py
Created February 12, 2014 23:35
Python Argument Parsing Inheritance
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 / gist:9488069
Created March 11, 2014 15:23
OS X - Change Chrome Language
defaults write com.google.Chrome AppleLanguages '(en-US)'
@yjaaidi
yjaaidi / splunk-user-agent-stats
Last active June 21, 2018 15:28
Splunk user-agent statistics
| search *
| lookup user_agents http_user_agent as user_agent
| replace "unknown" with "" in ua_device, ua_os_major, ua_os_minor
| replace "Windows*" with "Windows" in ua_os_family
| eval user_agent=ua_os_family + " - " + ua_family
| regex user_agent!="(unknown|PhantomJS)"
| eventstats dc(address) as total
| stats dc(address) as count by user_agent, total
| eval percentage=(count * 100/total)
| table percentage user_agent
// 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 June 8, 2016 10:51
TypeScript dynamic runtime contracts example
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 November 13, 2016 20:38
Webpack Dynamic File Name Resolution
/*
* Webpack config
*/
/* Use file-loader for images. */
{
test: /\.(gif|ico|jpg|png|svg)$/,
loader: 'file'
}
@yjaaidi
yjaaidi / prerender-clean-up.js
Last active February 1, 2022 17:01 — forked from imevro/gist:edfe9dea12196056467f
Clean up all cached pages in prerender.io from console
const cleanUp = async () => {
const response = await fetch('https://prerender.io/api/cached-pages?page=0&pageSize=100');
const itemList = await response.json();
const csrfToken = document.cookie.replace(/^.*XSRF-TOKEN=/, '').replace(/;.*$/, '');
const promiseList = itemList.map(item => fetch(`https://prerender.io/api/remove-cached-url?url=${encodeURIComponent(item.url)}`, {
method: 'DELETE',
headers: {
@yjaaidi
yjaaidi / wt-dynamic-component-injector.js
Created April 27, 2017 18:42
Angular dynamic component injector
@Injectable()
export class ComponentInjector {
constructor(
private _injector: Injector,
private _applicationRef: ApplicationRef,
private _componentFactoryResolver: ComponentFactoryResolver) {
}