Skip to content

Instantly share code, notes, and snippets.

@wahengchang
wahengchang / ShareCom.js
Last active April 20, 2022 08:45
Unit test, mocking components
import { InstallCom } from 'installComponent' //installed by npm
import UserCom from './userComponent'
export class ShareCom extends Component {
render() {
return (
<div>
<InstallCom para1='title1'/>
<UserCom para2='title2' />
</div>
@Jamesits
Jamesits / caddy.sh
Last active January 27, 2024 14:47
Install Caddy Server on Ubuntu with Systemd.
# Should work on all Debian based distros with systemd; tested on Ubuntu 16.04+.
# This will by default install all plugins; you can customize this behavior on line 6. Selecting too many plugins can cause issues when downloading.
# Run as root (or sudo before every line) please. Note this is not designed to be run automatically; I recommend executing this line by line.
apt install curl
curl https://getcaddy.com | bash -s personal dns,docker,dyndns,hook.service,http.authz,http.awses,http.awslambda,http.cache,http.cgi,http.cors,http.datadog,http.expires,http.filemanager,http.filter,http.forwardproxy,http.geoip,http.git,http.gopkg,http.grpc,http.hugo,http.ipfilter,http.jekyll,http.jwt,http.locale,http.login,http.mailout,http.minify,http.nobots,http.prometheus,http.proxyprotocol,http.ratelimit,http.realip,http.reauth,http.restic,http.upload,http.webdav,net,tls.dns.auroradns,tls.dns.azure,tls.dns.cloudflare,tls.dns.cloudxns,tls.dns.digitalocean,tls.dns.dnsimple,tls.dns.dnsmadeeasy,tls.dns.dnspod,tls.dns.dyn,tls.
@chokkan
chokkan / classification.ipynb
Last active December 19, 2017 18:35
Jupyter notebook for classification.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marszall87
marszall87 / docker-compose-install.sh
Created September 25, 2015 13:14
Simple script for installing latest Docker Compose on CoreOS >= 717.0.0
#!/bin/bash
mkdir -p /opt/bin
curl -L `curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.assets[].browser_download_url | select(contains("Linux") and contains("x86_64"))'` > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
@ktopping
ktopping / fake-s3-config.rb
Last active December 1, 2016 14:55
fake s3 config
# Add the following to /etc/hosts:
127.0.0.1 local.s3.endpoint local-bucket.local.s3.endpoint
# Run the following in your rails console, in order to create a bucket:
s3=AWS::S3.new(
:access_key_id => 'anything',
:secret_access_key => 'anything',
:s3_endpoint => 'local.s3.endpoint',
:s3_port => 4567,
:use_ssl => false
@martinnormark
martinnormark / PopoverView.js
Last active November 29, 2016 10:58
Backbone implementation of the Twitter Bootstrap Popover view
(function () {
App.Views.PopoverView = Backbone.View.extend({
initialize: function (options) {
_.bindAll(this, "render", "setContent", "show", "hide", "toggle", "destroy", "remove");
this.offsetTop = 30;
this.offsetLeft = 0;
@pies
pies / ExcelFormulas.js
Created November 29, 2012 04:55
Few Excel formulas - PMT, PPMT, XIRR - expressed in Javascript
/* Based on
* - EGM Mathematical Finance class by Enrique Garcia M. <egarcia@egm.co>
* - A Guide to the PMT, FV, IPMT and PPMT Functions by Kevin (aka MWVisa1)
*/
var ExcelFormulas = {
PVIF: function(rate, nper) {
return Math.pow(1 + rate, nper);
},
@madeye
madeye / ProxySettings.java
Created April 4, 2012 01:53
Set proxy for Android Webview
package me.madeye;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.http.HttpHost;
import android.content.Context;
@javiervidal
javiervidal / gist:1433880
Created December 5, 2011 15:05
To access url helpers (url_for, etc) from Rails console (Rails 3)
include Rails.application.routes.url_helpers
default_url_options[:host] = "localhost"
@bradleybuda
bradleybuda / cache_instrumentation.rb
Created January 22, 2010 06:25
simple performance stats on Rails cache usage
class CacheInstrumentation
def self.filter(controller)
begin
cache_timing = { :min => nil, :max => nil, :keys => [], :count => 0, :total => 0.0 }
# redefine Rails.cache.fetch for this request
real_fetch_method = Rails.cache.method(:fetch)
Rails.cache.metaclass.send(:define_method, :fetch) do |*args, &block|
begin
start_time = Time.now.to_f