Skip to content

Instantly share code, notes, and snippets.

View alonronin's full-sized avatar
:octocat:
Me. Write. Code.

Alon Valadji alonronin

:octocat:
Me. Write. Code.
View GitHub Profile
@elektronik2k5
elektronik2k5 / .eslintrc.cjs
Last active May 22, 2024 18:09
Static analysis config
const rootConfig = require('../../.eslintrc.cjs');
/* eslint-disable */
// cspell:ignore singleline linebreak multilines paren
const OFF = 'off';
const WARN = 'warn';
const ERROR = 'error';
module.exports = {
extends: [
...rootConfig.extends,
@sstackus
sstackus / App.js
Last active June 24, 2024 16:05
Compose React context providers
import React from "react";
import Compose from "./Compose.js";
import Context from "./Context.js";
export default function App() {
const [foo] = React.useState(1);
const [bar] = React.useState(2);
return (
<Compose
@kettanaito
kettanaito / client-App.jsx
Last active April 21, 2023 22:16
React - SSR (Server-side rendering)
// Root of the actual application.
// Feel free to branch from here, create routes and any other things
// rendered on both browser and server.
//
// Don't use modules relying on "window" here, as it would throw on the serfver.
// If using any such logic, move it to "client-index" instead, as its being rendered
// in the browser only.
import React from 'react'
const App = () => (
@matthewpalmer
matthewpalmer / pod.yaml
Created July 21, 2018 04:13
kubernetes nginx php-fpm pod
# Create a pod containing the PHP-FPM application (my-php-app)
# and nginx, each mounting the `shared-files` volume to their
# respective /var/www/html directories.
kind: Pod
apiVersion: v1
metadata:
name: phpfpm-nginx-example
spec:
volumes:
@mousetree
mousetree / config.yml
Created July 10, 2018 16:18
CircleCI v2.0 config for deployment to Google Kubernetes Engine (GKE)
version: 2
jobs:
build_and_test:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
@erikyuntantyo
erikyuntantyo / react-native-offline-bundling-android
Last active October 29, 2023 06:36
Build react-native offline bundling into android
# create assets folder in the current project
$ mkdir android/app/src/main/assets
# create bundle script
$ react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
# execute command to run android to create debug apk
$ react-native run-android
# Or change to android folder
@alvaropinot
alvaropinot / map-to-object.js
Created October 3, 2017 17:58
"FUNctional" 😜 Map 🗺 to object 🔑
const obj = { a: 1, c: 3, b: 2 }
// Map from object.
const myMap = new Map(Object.entries(obj))
// Map to Object.
// NOTE: Keys will be cast to strings by `.toString`, so any "complex" key like for example `[1, 2]` will become `1,2`
const newObj = [...myMap.entries()]
.reduce((acc, [key, value]) => (Object.assign(acc, { [key]: value })), {})
@eiriklv
eiriklv / avoiding-exceptions.js
Last active February 2, 2019 12:13
Exception free JavaScript?
/**
* WHY? - BECAUSE EXCEPTIONS/TRY/CATCH IS A GLOBAL HORRIBLE MESS :-(
* Check out error handling in golang: https://blog.golang.org/error-handling-and-go
*/
/**
* Wrap an "unsafe" promise
*/
function safePromise(promise) {
return promise
@paulirish
paulirish / bling.js
Last active November 4, 2024 17:48
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
};
NodeList.prototype.__proto__ = Array.prototype;
var Bar1 = base => class extends base {
componentWillMount(){
super.componentWillMount();
console.log('Bar1');
}
};
var Bar2 = base => class extends base {
componentWillMount(){
super.componentWillMount();