Skip to content

Instantly share code, notes, and snippets.

class PI
@@TIME = 10000000
attr :circle, :square
def initialize
@circle = 0
@square = 0
calculate_pi
end
// http://stackoverflow.com/questions/10730362/get-cookie-by-name
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
class ColorCard extends React.Component {
constructor(props) {
super(props);
this.state = {color: ''};
this.handleSubmit = this.handleSubmit.bind(this);
// this.handleChange = this.handleChange.bind(this);
}
handleSubmit(e) {
const List = props => (
<ul>
{
props.items.map( (item, index) => <li key={index}>{item}</li> )
}
</ul>
)
class TodoList extends React.Component {
constructor(props) {
// SyntheticEvent
// 'this' inside your event handler refers to the component the event handler lives in
class PlusButton extends React.Component {
render(){
const buttonStyle= {
fontSize: '1em',
width: 30,
height: 30,
@pinkmomo027
pinkmomo027 / countSetBits.js
Created March 19, 2018 19:58
JS count binary set bits
i.toString(2).replace(/0/,'').length
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
i := 0;
z := float64(1)
for i < 10 {
func Sqrt(x float64) float64 {
i := 1;
z := float64(1)
t := z - (z*z - x) / (2*z)
delta := 0.0000001
for math.Abs(t-z) > delta {
z = t
t = z - (z*z - x) / (2*z)
fmt.Println(z)
@pinkmomo027
pinkmomo027 / docker-cleanup-resources.md
Created May 9, 2018 16:23 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@pinkmomo027
pinkmomo027 / nativeJavaScript.js
Created May 30, 2018 23:21 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests