Skip to content

Instantly share code, notes, and snippets.

@chengsokdara
chengsokdara / useStore.js
Last active June 20, 2024 10:09
React global state in 15 lines of code.
// Author: Sokdara Cheng
// Contact me for web or mobile app development using React or React Native
// https://chengsokdara.github.io
import React, { createContext, useContext, useReducer } from "react";
import initialState from "./initialState"; // object of initial states
import reducer from "./reducer"; // https://reactjs.org/docs/hooks-reference.html#usereducer
const Store = createContext({
dispatch: () => null,
state: initialState,
});
@darbyluv2code
darbyluv2code / MyLoggerConfig.java
Last active February 5, 2023 06:34
Spring Logging for Spring 5.1 - XML Configuration
package com.luv2code.springdemo;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class MyLoggerConfig {
@darbyluv2code
darbyluv2code / Student.java
Created October 3, 2016 14:32
FAQ: How to populate radiobuttons with items from Java class like we did with selectlist?
package com.luv2code.springdemo.mvc;
import java.util.LinkedHashMap;
public class Student {
private String firstName;
private String lastName;
private String favoriteLanguage;
@tzkmx
tzkmx / jquery-redux-example.js
Created August 11, 2016 23:40
Redux with jQuery simple example
// original from:https://codepen.io/mdd/pen/wGRqbw
// Reducer
const counter = (state = 0, actions) => {
switch (actions.type) {
case 'INCREMENT': return state + 1;
case 'DECREMENT': return state - 1;
default: return state
}
}
@nassarofficial
nassarofficial / Active Contour Model Greedy Implementation
Created May 1, 2016 16:06
Active Contour Model Greedy Implementation
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Active Contour Model Greedy Algorithm By William and Shah"
]
},
{
@plucury
plucury / gist:3009512
Created June 28, 2012 06:33
美化git日志展示
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"