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 / 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
@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 / 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 / gist:9488069
Created Mar 11, 2014
OS X - Change Chrome Language
View gist:9488069
defaults write com.google.Chrome AppleLanguages '(en-US)'
@yjaaidi
yjaaidi / splunk-user-agent-stats
Last active Jun 21, 2018
Splunk user-agent statistics
View splunk-user-agent-stats
| 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
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 / prerender-clean-up.js
Last active Jan 6, 2021 — forked from evgenyrodionov/gist:edfe9dea12196056467f
Clean up all cached pages in prerender.io from console
View prerender-clean-up.js
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 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) {
}