Skip to content

Instantly share code, notes, and snippets.

Samuel engineersamuel

Block or report user

Report or block engineersamuel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@engineersamuel
engineersamuel / gist:5416671
Created Apr 18, 2013
Example knockout expressions
View gist:5416671
<!-- variable (usually a property of the current view model -->
<div data-bind="visible: shouldShowMessage">...</div>
<!-- comparison and conditional -->
The item is <span data-bind="text: price() > 50 ? 'expensive' : 'cheap'"></span>.
<!-- function call and comparison -->
<button data-bind="enable: parseAreaCode(cellphoneNumber()) != '555'">...</button>
<!-- function expression -->
@engineersamuel
engineersamuel / gist:5416673
Created Apr 18, 2013
Example knockout expressions
View gist:5416673
<!-- variable (usually a property of the current view model -->
<div data-bind="visible: shouldShowMessage">...</div>
<!-- comparison and conditional -->
The item is <span data-bind="text: price() > 50 ? 'expensive' : 'cheap'"></span>.
<!-- function call and comparison -->
<button data-bind="enable: parseAreaCode(cellphoneNumber()) != '555'">...</button>
<!-- function expression -->
@engineersamuel
engineersamuel / gist:5416674
Created Apr 18, 2013
Example knockout expressions
View gist:5416674
<!-- variable (usually a property of the current view model -->
<div data-bind="visible: shouldShowMessage">...</div>
<!-- comparison and conditional -->
The item is <span data-bind="text: price() > 50 ? 'expensive' : 'cheap'"></span>.
<!-- function call and comparison -->
<button data-bind="enable: parseAreaCode(cellphoneNumber()) != '555'">...</button>
<!-- function expression -->
@engineersamuel
engineersamuel / ko_expressions.html
Created Apr 18, 2013
Example knockout expressions
View ko_expressions.html
<!-- variable (usually a property of the current view model -->
<div data-bind="visible: shouldShowMessage">...</div>
<!-- comparison and conditional -->
The item is <span data-bind="text: price() > 50 ? 'expensive' : 'cheap'"></span>.
<!-- function call and comparison -->
<button data-bind="enable: parseAreaCode(cellphoneNumber()) != '555'">...</button>
<!-- function expression -->
@engineersamuel
engineersamuel / gist:5416681
Created Apr 18, 2013
Example knockout expressions
View gist:5416681
<!-- variable (usually a property of the current view model -->
<div data-bind="visible: shouldShowMessage">...</div>
<!-- comparison and conditional -->
The item is <span data-bind="text: price() > 50 ? 'expensive' : 'cheap'"></span>.
<!-- function call and comparison -->
<button data-bind="enable: parseAreaCode(cellphoneNumber()) != '555'">...</button>
<!-- function expression -->
@engineersamuel
engineersamuel / thread_utils.py
Created Aug 27, 2013
Simple thread pool in python
View thread_utils.py
class OneOffThreadPool(threading.Thread):
def __init__(self, max_concurrent_threads=10):
threading.Thread.__init__(self)
self.threads = []
self.threads_running = []
self.thread_count = 0
self.max_concurrent_threads = max_concurrent_threads
self.log = logging.getLogger(name="OneOffThreadPool")
self.log.setLevel(logging.INFO)
@engineersamuel
engineersamuel / mkv2mp4.sh
Created Jun 22, 2015
Encode mp4 files for DLNA streaming, works with TVs, devices, and PS4
View mkv2mp4.sh
#!/bin/bash
# ffmpeg installed via: brew install ffmpeg --enable-libx264 --enable-libfaac --enable-libass --with-faac --with-ass --with-tools
# ln -s /Applications/mkv2mp4.sh /usr/bin/mkv2mp4
MKV=$1
echo "MKV: $MKV"
MP4=`echo $MKV | sed 's/\.mkv/\.mp4/'`
echo "MP4: $MP4"
CMD="ffmpeg -y -i $MKV -vcodec copy -acodec libfaac -tune film $MP4"
echo "Executing: $CMD"
View IsotopeResponseRenderer.jsx
constructor(props, context) {
super(props, context);
// Copied from http://codepen.io/desandro/pen/nFrte
this.filterFns = {
// show if number is greater than 50
numberGreaterThan50: function () {
var number = $(this).find('.number').text();
return parseInt( number, 10 ) > 50;
},
View IsotopeResponseRenderer.jsx
shouldComponentUpdate(nextProps, nextState) {
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
}
View IsotopeResponseRenderer.jsx
import React from "react";
import shallowEqual from "react-pure-render/shallowEqual"
// Flux
import connectToStores from 'alt/utils/connectToStores';
import FilterSortActions from '../flux/actions/FilterSortActions';
import FilterSortStore from '../flux/stores/FilterSortStore';
@connectToStores
export default class IsotopeResponseRenderer extends React.Component {
You can’t perform that action at this time.