Skip to content

Instantly share code, notes, and snippets.

View pgilad's full-sized avatar
🔭

Gilad Peleg pgilad

🔭
View GitHub Profile
@sitano
sitano / ansible-common-default.yaml
Created July 30, 2015 15:27
ansible task example on how to setup kernel.mm.transparent_hugepage (block) if it exists
# file: roles/common/tasks/item.yml
- name: be sure basic packages are installed
apt: pkg={{item}} state=latest update_cache=yes
tags: common
with_items:
- git
- subversion
- vim
- block:
@yoavweiss
yoavweiss / Remap_esc_key.sh
Created October 7, 2018 20:14
Remap § to Esc and Esc to F24
#!/bin/bash
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000029}, {"HIDKeyboardModifierMappingSrc":0x700000029,"HIDKeyboardModifierMappingDst":0x700000073}]}'
@pgilad
pgilad / getSubdomain.js
Last active October 10, 2018 11:55
Regex for matching subdomains in document.location.hostname
var getSubdomain = function (baseDomain) {
if (!baseDomain) {
return null;
}
var regSub = new RegExp('^((?!' + baseDomain + '|www)([^.]*))', 'g');
var _subdomain = document.location.hostname.match(regSub);
if (_subdomain && _subdomain[0]) {
return _subdomain[0];
} else {
@pgilad
pgilad / DataSender.java
Last active December 26, 2018 07:33
DataSender using Netty Reactive Client
package data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.ByteBufFlux;
import reactor.netty.http.client.HttpClient;
import reactor.retry.Retry;
import settings.Settings;
@pgilad
pgilad / build.gradle
Last active December 26, 2018 07:33
How to create reproducible builds in spring using buildInfo
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
springBoot {
mainClassName = 'com.blazemeter.dagger.DaggerApplication'
buildInfo {
properties {
time = null
@pgilad
pgilad / account.ts
Last active December 26, 2018 07:34
An example of a model wrapping read only state using Typescript
import _ from 'lodash';
import produce from 'immer';
import { IAccount } from '../../types/account';
import { IData, IModifiable, ProduceRecipe } from '../metadata';
/**
* An account model
*/
export class Account implements IModifiable<IAccount>, IData<IAccount> {
readonly data: Readonly<IAccount>;
@pgilad
pgilad / script.js
Created December 2, 2018 13:19
Minimal compiler for typescript files
const ts = require('typescript');
const tsConfig = require('./tsconfig.json');
const config = tsConfig.compilerOptions;
function compile(fileNames, options) {
if (fileNames.filter(Boolean).length === 0) {
console.log('No files');
return;
}
@pgilad
pgilad / Constants.java
Last active December 26, 2018 07:37
An example of a pre-set scheduler for paralleling reactive work
public static final Scheduler scheduler = Schedulers.fromExecutorService(new ThreadPoolExecutor(4, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()))
@pgilad
pgilad / test.php
Created October 24, 2018 07:54
Php instance property mutation
<?php
class State {
public $foo = 0;
}
class Mutator {
public function mutateState(State $state) {
$state->foo = 4;
}
@pgilad
pgilad / Dockerfile
Last active January 2, 2019 16:13
Dockerfile to create a zip for AWS Lambda code based on Python 2.7 and Pipenv
FROM amazonlinux:latest
RUN yum -y update && yum install -y gcc python-devel zip which
RUN curl https://bootstrap.pypa.io/get-pip.py | python -
RUN pip install pipenv
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV SOURCE_DIR lambdas