// /swr/project.js
import useSWR, { mutate } from 'swr'
export async function fetchProject (id) {
mutate(`/api/project/${id}`, fetch(`/api/project/${id}`))
}
export default function useProject (id) {
// don't pass the fetcher so it won't fetch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name sxzy | |
| // @namespace https://clannadxr.com/ | |
| // @version 0.5 | |
| // @author clannadxr | |
| // @match http://122.191.123.18:18080/DrcomManager/index.do | |
| // @match http://122.191.123.18:18080/MAuth/home/toHome | |
| // @match http://122.191.123.18:18080/DrcomSso/sso/index | |
| // @grant GM_xmlhttpRequest | |
| // @grant GM_setValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| speedups: | |
| rescue_vs_respond_to: true | |
| module_eval: true | |
| shuffle_first_vs_sample: true | |
| for_loop_vs_each: true | |
| each_with_index_vs_while: false | |
| map_flatten_vs_flat_map: true | |
| reverse_each_vs_reverse_each: true | |
| select_first_vs_detect: true | |
| sort_vs_sort_by: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let readBinaryFile = (filepath) => { | |
| return NSData.alloc().initWithContentsOfFile(filepath); | |
| }; | |
| let path = "path/to/file.json" | |
| let data = readBinaryFile(path) | |
| let contents = NSString.alloc().initWithData_encoding(data, NSUTF8StringEncoding) | |
| console.log(JSON.parse(contents)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://xmanyou.com/cocos-creator-jie-tu-gong-neng-dai-ma/ | |
| // 截图组件 (如果没有提前添加Camera组件,则会自动添加一个默认参数的Camera) | |
| // 语言:Typescript | |
| // Cocos Creator 版本: 2.0.5 | |
| // 使用方法: | |
| // 1. 在场景里添加一个Node, 把这个组件拖进去 | |
| // 2. 在需要截图的地方,import, 然后调用:ScreenShotNode.take() | |
| // Screenshot component | |
| // typescript |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj | |
| Cloning into 'my-awesome-proj'... | |
| ssh: connect to host github.com port 22: Connection timed out | |
| fatal: Could not read from remote repository. | |
| $ # This should also timeout | |
| $ ssh -T git@github.com | |
| ssh: connect to host github.com port 22: Connection timed out | |
| $ # but this might work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upstream backend { | |
| server 127.0.0.1:3000; | |
| } | |
| server { | |
| listen 80; | |
| server_name your.hostname.com; | |
| proxy_set_header Host $http_host; | |
| access_log /tmp/test-access.log debug; | |
| rewrite_log on; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| import { Redirect } from 'react-router' | |
| export default class ContactForm extends Component { | |
| constructor () { | |
| super(); | |
| this.state = { | |
| fireRedirect: false | |
| } | |
| } |
Convert SVG to canvas on-the-fly.
This article from MDN explains the process: Drawing DOM object into a canvas. This works for any DOM object, not just SVG. Not sure if this is well supported by older browsers. Works on Chrome, Firefox and IE 10 for me. The bar chart is a fork of this block by Mike Bostock: Canvas Bar Chart.
NewerOlder