Skip to content

Instantly share code, notes, and snippets.

View pbedat's full-sized avatar

Patrick Bédat pbedat

View GitHub Profile
@pbedat
pbedat / main.go
Created April 14, 2025 19:03
watermill-sql benchmark
package main
import (
"context"
std_sql "database/sql"
"fmt"
"log"
"sync"
"sync/atomic"
"time"
@pbedat
pbedat / forms.tsx
Last active April 30, 2019 13:01
React Hooks: useForm
import React, { useReducer } from "react";
import { Input, FormFeedback, Alert, Button, FormGroup } from "reactstrap";
import { createAction, ActionType, getType } from "typesafe-actions";
import { first, values, fromPairs, keyBy, mapValues } from "lodash";
/**
* This story shows how the validation and form states should be display.
* It is also a good example for hooks!
*/
const FormsUxStory = () => {
declare module 'react-jss' {
import * as React from 'react';
export interface CSSProperties extends React.CSSProperties {
composes?: string | string[]
}
export type StyleSheet<Props = {}>
= Record<
angular.module("xSources.Security").directive("xsLoginForm", function (AuthenticationApi) {
return {
restrict: "EA",
controller: function ($scope) {
$scope.user = {};
AuthenticationApi.initialize();
angular
.module("xSources.Security")
.service("AuthenticationApi", function ($rootScope, ipCookie, SessionModel, Restangular) {
var my = this;
my.initialize = function () {
SessionModel.get().then(function (session) {
if (session == null || !session.IsValid) {
$rootScope.$broadcast("authentication:required");
<div ng-app="xSources.Security">
<xs:login-form></xs:login-form>
</div>
<div id="main-app" style="display: none;">
{{session}}
<button type="button" ng-click="logout()">
logout
</button>
$stateProvider.state("wf", {
resolve: {
waitForLogin: function(UserModel){
return UserModel.isLoggedIn();
}
}
}).state("wf.employee", {
abstract: true,
url: "employees/:id",
$stateProvider.state("wf.employee", {
abstract: true,
url: "employees/:id",
resolve: {
employee: function(EmployeeModel, $stateParams){
return EmployeeModel.get($stateParams.id);
}
}
}).state("wf.employee.salary", {
//...
@pbedat
pbedat / GetTestcasesByProject.js
Created March 9, 2014 20:32
GetTestcasesByProject
angular.module("xAmine").factory("GetTestcasesByProject", function(Backend){
var filterBy = function(projectId){
return function(testcases){
return _(testcases).where({ProjectId: projectId});
};
};
return function(projectId){
return Backend.Get("Testcases").then(filterBy(projectId));
@pbedat
pbedat / GetTestcasesAvailableToCycle.js
Created March 9, 2014 20:30
GetTestcasesAvailableToCycle
angular.module("xAmine").factory("GetTestcasesAvailableToCycle", function(GetTestcasesByProject){
var filterTestcasesIn = function(cycle){
return function(testcases){
var testCasesInCycle = _.chain(cycle.Tests.Items).pluck("Testcase").pluck("Id").value();
return _(testcases).reject(function(testcase){
return _(testCasesInCycle).contains(testcase.Id);
});
};