Skip to content

Instantly share code, notes, and snippets.

@a9
a9 / effective-graphql-and-antd.md
Created September 12, 2018 07:41
Effective GraphQL + Antd

高效的 GraphQL + Antd

本文原载于我的独立博客 https://lutaonan.com/blog/effective-graphql-and-antd/

在过去的几年,不论是面向内部的系统,还是面向外部的产品,我们都大量地使用了 Ant.Design —— 一个基于 React 的 UI 组件库。

在做内部系统时,Ant.Design 解决了几乎 60% 的问题。剩下的问题在业务逻辑和代码组织的复杂度。我见过很多内部系统因为滥用状态管理而使代码变得复杂,他们之所以使用状态管理库,并不是因为应用的状态复杂,而是因为需要一个状态树来管理网络请求的状态、接口返回的数据等等这些和接口相关的状态。

真的需要状态管理库吗?在之前,我没有信心回答这个问题。但在使用了 GraphQL (Apollo) 后,我确信,在大多数场景,你不再需要状态管理。

@LastZactionHero
LastZactionHero / cheatsheet.v
Last active January 30, 2024 15:11
Verilog Syntax Cheat Sheet
module module_name(signal_a, signal_b);
input [7:0] signal_a;
output signal_b;
endmodule
parameter n = 32;
integer k;
for (k = 0; k < n; k + 1)
begin
@Era-Dorta
Era-Dorta / tensorflow_cc_windows
Last active January 8, 2018 18:32
Configuration for a Visual Studio project that depends on tensorflow.dll in C++
Follow instructions in the following link to compile tensorflow.
Build as a shared library -Dtensorflow_BUILD_SHARED_LIB=ON
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake
Create new empty project in visual studio.
A good example to test as main.cpp would be
https://github.com/tensorflow/tensorflow/blob/r1.2/tensorflow/examples/label_image/main.cc
The following assumes that Tensorflow was downloaded in C:\tensorflow-r1.2
************
@swarminglogic
swarminglogic / SmartObjectPool.h
Last active June 26, 2022 14:18
SmartObjectPool: A RAII-style implementation of the object pool pattern that uses smart pointers to automatically return acquired objects to the pool when deleted.
#include <memory>
#include <stack>
#include <stdexcept>
template <class T, class D = std::default_delete<T>>
class SmartObjectPool
{
private:
struct ReturnToPool_Deleter {
explicit ReturnToPool_Deleter(std::weak_ptr<SmartObjectPool<T, D>* > pool)
@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active July 16, 2024 17:25
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 25, 2024 09:09
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@filsinger
filsinger / fnv_hash_example.cpp
Created October 1, 2011 06:36
C++11 : FNV-1 and FNV-1a compile-time string hashing
// C++11 32bit FNV-1 and FNV-1a string hasing (Fowler–Noll–Vo hash)
//
// Requires a compiler with C++11 support
// See main(...) for examples
#include <iostream>
#include <cassert>
namespace hash
{
@eliotb
eliotb / aisgen.py
Last active October 26, 2022 16:35
Tools for working with Texas Instruments COFF and AIS files
#!/usr/bin/env python
'''Read fully linked TI COFF file, and generate AIS format file
Commandline parameters
enable sequential read,
pll and emifb configuration
pinmux configuration
enable checksums
'Eliot Blennerhassett' <eblennerhassett@audioscience.com>
@jonleighton
jonleighton / base64ArrayBuffer.js
Last active June 19, 2024 13:39
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: