Skip to content

Instantly share code, notes, and snippets.

View email2vimalraj's full-sized avatar
🎯
Focusing

VimalRaj Selvam email2vimalraj

🎯
Focusing
View GitHub Profile
@jamesfulford
jamesfulford / useTime.js
Last active December 13, 2022 09:07
useTime() React hook
//
// useTime hook
//
import { useEffect, useState } from 'react';
export const useTime = (refreshCycle = 100) => {
// Returns the current time
// and queues re-renders every `refreshCycle` milliseconds (default: 100ms)
const [now, setNow] = useState(getTime());
@danmakenoise
danmakenoise / test.js
Last active February 29, 2024 20:23
Unit Testing Children of React Context API Consumers with Enzyme
// Component.js
const Component = props => (
<MyContext.Consumer>
{(context) => (
<Foo
bar={props.bar}
baz={context.baz}
/>
)}
</MyContext.Consumer>
anonymous
anonymous / nodejs.md
Created September 12, 2017 08:04
nodejs
/* 

Read a ini file

[Section1]
Param1=value1
[Section2]
Param2=value2
@aliok
aliok / jenkinsfile-commons.groovy
Created April 26, 2017 12:35
Sample advanced Jenkins pipeline
/**
* This file provides common stuff to be used in the pipelines.
* It is important to load it after repo checkout is done: see https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md#triggering-manual-loading
*
*/
/**
* Dumps some info about the environment.
* @return
*/
@shettayyy
shettayyy / pre-commit-eslint
Last active December 10, 2021 05:27
Pre-commit hook for Linting JS with ESLint before commit.
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
ESLINT="$(git rev-parse --show-toplevel)/node_modules/.bin/eslint"
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
@albertojg
albertojg / combine-path-mapper.js
Created December 9, 2016 07:04
Transform import statement
const fs = require('fs');
const args = process.argv.slice(2);
const options = args
.reduce((result, arg) => {
const splittedArg = arg.split('=');
const key = splittedArg[0].replace('--', '');
const value = splittedArg[1];
result[key] = value;
@ryantuck
ryantuck / ansible-localhost.md
Last active April 3, 2024 15:21
super fast way to start testing ansible stuff locally without VMs

set up ansible to work on localhost

i've found this useful for debugging ansible modules and syntax without having to use VMs or test in dev environments.

install ansible

pip install ansible

make some relevant config files

@yanmhlv
yanmhlv / example.go
Created February 8, 2016 14:49
JSONB in gorm
package main
import (
"database/sql/driver"
"encoding/json"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@revolunet
revolunet / python-es6-comparison.md
Last active April 22, 2024 19:22
# Python VS JavaScript ES6 syntax comparison

Python VS ES6 syntax comparison

Python syntax here : 2.7 - online REPL

Javascript ES6 via Babel transpilation - online REPL

Imports

import math