Skip to content

Instantly share code, notes, and snippets.

@mikechau
mikechau / video.jsx
Last active August 20, 2021 12:50
videojs react component
var React = require('react');
var cx = require('classnames');
var vjs = require('video.js');
var _forEach = require('lodash/collection/forEach');
var _debounce = require('lodash/function/debounce');
var _defaults = require('lodash/object/defaults');
var DEFAULT_HEIGHT = 800;
var DEFAULT_WIDTH = 600;
var DEFAULT_ASPECT_RATIO = (9 / 16);
@mikechau
mikechau / applet.js
Last active April 8, 2024 05:22
cinnamon-system-monitor-applet
/*
system-monitor@ebbes applet
Cinnamon applet displaying system informations in gnome shell status bar, such as memory usage, cpu usage, network rates…
forked from gnome-shell extension (for gnome-shell 3.2) to Cinnamon applet by [email protected]
Changes that were done:
* Removed battery functionality
* Removed tooltips (as they were crashing Cinnamon)
* Implemented simpler tooltips
* Some backports from gnome-shell 3.4 extension
@mikechau
mikechau / gist:c356fd1c06957929a2c1
Created May 25, 2015 04:27
ansible get_url output
ok: [localhost] => {
"dropbox_deb": {
"changed": true,
"checksum": "6778c8ec429ae14dfbc43d0c6fddd2a59ef0ef23",
"dest": "/tmp/dropbox/dropbox.deb",
"gid": 1000,
"group": "mike",
"invocation": {
"module_args": "",
"module_name": "get_url"
- test ram
- install ubuntu
- install cinnamon
- install cinnamon addons
- firefox addons and settings
- sublime
- clementine
- intel libvdpau-va-gl and liba-intel-driver
- flash
- dropbox
/*
* Webpack production build configuration
*
* This file is set up for building assets ready to be served in production.
*/
'use strict';
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
export var getAPI = (endpoint, data = {}, opts = {}) => {
let url = makeUrl(endpoint, opts);
let request = superagent.get(url).query(data);
let promise = makePromise(request);
return promise;
};
var makePromise = (request) => {
return new Promise(function(resolve, reject) {
https://groups.google.com/forum/#!topic/reactjs/Xv9_kVoJJOw
I found this confusing as well and actually found this thread after a search for something like 'react bind null' or something. So I'll briefly explain my surface-level understanding for future searchers.
It turns out that react automatically binds methods to 'this' on component mount. This is helpful because it allows you to directly pass functions (e.g. this.handleChange) to a child component without worrying about the value of 'this' when the function is actually called. React then the replaces the standard Function.prototype.bind method with its own function to help stop you from doing anything silly (like trying to change the already-bound value of 'this'), so you instead have to pass 'null' to say "I understand this will only alter the arguments".
However, react (for whatever reason) does not do this for function calls within the same component (i.e. this.myFunction()). Possibly because it's a little pointless - 'this' will be the correct va
http://crunchbang.org/forums/viewtopic.php?pid=414074#p414074
This happens because nvidia driver overrode OpenGL library (libGL.so). This workaround works for me on kubuntu 14.04.
1) close dropbox session
2) find your nvidia system folder: in my systems it's /usr/lib/nvidia-304 (if you using another version of nvidia driver, for instance nvidia-331, your directory should be /usr/lib/nvidia-331
3) find dropbox system library: in my system it's /var/lib/dropbox/.dropbox-dist/dropbox-lnx.x86_64-3.0.5/
4) backup your's dropbox OpenGL library: #mv libGL.so.1 libGL.so.1_backup
5) make symbolic link to nvidia's OpenGL library: #ln -sf /usr/lib/nvidia-304/libGL.so.304.125 /var/lib/dropbox/.dropbox-dist/dropbox-lnx.x86_64-3.0.5/libGL.so.1
6) start up dropbox
{
esprima: {
transforms: [
{
type: 'replace',
enter: function(node, parent) {
if (node.type === 'VariableDeclaration') {
var declarations = node.declarations;
var newDeclarations = declarations.map(function(declaration) {
@mikechau
mikechau / 00_README.md
Last active May 19, 2024 13:34
Logging Rails 4 to Syslog, formatted w/ Logstash

Logging Rails 4 to Syslog, formatted w/ Logstash

Getting Started

Steps to get Rails 4 saving its output to Syslog via Rsyslog. This assumes you are on CentOS, but should be pretty adaptable to any other distribution. Ruby 2.0+ is also required.

  1. Add the gems lograge and logstash-event to your Gemfile. Feel free to remove from production if you'd like to test it in development as well or something.
  2. Update production.rb with the lograge settings and set the logger to Syslog::Logger.
  3. Add the conf files to /etc/rsyslog.d/. /etc/rsyslog.conf should have $IncludeConfig /etc/rsyslog.d/*.conf enabled, so it will load any additional configs from /etc/rsyslog.conf.