Skip to content

Instantly share code, notes, and snippets.

View afc163's full-sized avatar
🎃
Closing issues

afc163 afc163

🎃
Closing issues
View GitHub Profile
@ChristopherBiscardi
ChristopherBiscardi / gatsby.config.js
Created January 20, 2016 19:02
Extracting Stylesheets with Gatsby
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = function(config, env) {
if(env === 'static') {
config.removeLoader('css');
config.loader('css', function(cfg) {
cfg.test = /\.css$/;
cfg.loader = ExtractTextPlugin.extract('css?minimize');
return cfg
})
@chrisladd
chrisladd / text.js
Created February 9, 2016 19:56
Text Rendering for Sketch
// text.js
function replaceSubstring(inSource, inToReplace, inReplaceWith) {
var outString = inSource;
while (true) {
var idx = outString.indexOf(inToReplace);
if (idx == -1) {
break;
}
@usagimaru
usagimaru / NSImage+TintColor.swift
Last active October 12, 2023 13:39
NSImage+TintColor
import Cocoa
// This will work with Swift 5
extension NSImage {
func image(with tintColor: NSColor) -> NSImage {
if self.isTemplate == false {
return self
}
let image = self.copy() as! NSImage
@aoxu
aoxu / forward.sh
Created September 29, 2016 03:01
forward socks5 to http/https
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install privoxy
vim /usr/local/etc/privoxy/config
forward-socks5 / 127.0.0.1:1080 .
brew services start privoxy
export https_proxy=http://127.0.0.1:8118;export http_proxy=http://127.0.0.1:8118
import React from 'react'
import Router from 'react-router/BrowserRouter'
import Match from 'react-router/Match'
import Link from 'react-router/Link'
import Redirect from 'react-router/Redirect'
function elementInViewport(el) {
var top = el.offsetTop
var left = el.offsetLeft
var width = el.offsetWidth
@dceddia
dceddia / config-overrides.dev.js
Created December 6, 2016 21:12
Customize Create React App without ejecting
module.exports = function(config) {
// Generate sourcemaps
config.devtool = 'source-map';
// Compile i18n messages throughout the project into JSON files
config.module.loaders[0].query.plugins = [
["react-intl", {
"messagesDir": "./build/messages/"
}]
];
@afc163
afc163 / cascader-address-options.js
Last active December 14, 2023 01:47
Address options for antd cascader
import provinces from 'china-division/dist/provinces.json';
import cities from 'china-division/dist/cities.json';
import areas from 'china-division/dist/areas.json';
areas.forEach((area) => {
const matchCity = cities.filter(city => city.code === area.cityCode)[0];
if (matchCity) {
matchCity.children = matchCity.children || [];
matchCity.children.push({
label: area.name,
@threepointone
threepointone / deep-string.js
Last active March 13, 2019 20:09
deep update of text in a react component
import React from 'react'
import { render } from 'react-dom'
// with fiber, we'll be able to write components that update text deep
// inside another string without wrapper dom, or rerendering the whole component
// before
class Lorem extends React.Component {
state = {
str: ''
@Kruemelkatze
Kruemelkatze / ! Theming Ant Design with Sass and Webpack.md
Last active June 4, 2024 21:55
Theming Ant Design with Sass and Webpack

Theming Ant Design with Sass and Webpack

This is a solution on how to theme/customize Ant Design (which is written in Less) with Sass and webpack. Ant itself offers two solutions and a related article on theming, but these are only applicable if you use Less, the antd-init boilerplate or dva-cli.

What this solution offers:

  • use a single sass-file to customize (no duplicate variables for your project and Ant)
  • hot reload compatibility
  • no dependencies on outdated npm modules
  • easy integration with your existing webpack setup (webpack 3+ tested)
@coin8086
coin8086 / using-proxy-for-git-or-github.md
Last active June 11, 2024 03:20
Use Proxy for Git/GitHub

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocol you use. And there're two common protocols: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocol. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p