Skip to content

Instantly share code, notes, and snippets.

View imagineLife's full-sized avatar

Eric imagineLife

View GitHub Profile
@imagineLife
imagineLife / chart.js
Created February 21, 2018 21:57 — forked from chrtze/chart.js
Line Chart Example
var Chart = (function(window,d3) {
var svg, data, x, y, xAxis, yAxis, dim, chartWrapper, line, path, margin = {}, width, height, locator;
var breakPoint = 768;
d3.csv('data.csv', init); //load data, then initialize chart
//called once the data is loaded
function init(csv) {
@imagineLife
imagineLife / gist:4d90d0b0eea8e4f29343049053fdff67
Created February 7, 2018 12:31 — forked from eBrou/gist:68759d77ec5465b66655cdf4599dd876
Binary & Bitwise Operators Exercises
// Implement a function that takes in an integer and prints out its two's complement value by following the algorithm described above. Hint: to invert the bits of a number you can use the "~" operator. For example ~25 will invert the bits of the integer 25.
function twosComplement(int){
console.log('int to string is ' + int.toString(2));
const binaryInt = int.toString(2);
// console.log(binaryInt.length)
let result = '';
for (var i = 0; i < binaryInt.length; i++){
if (binaryInt[i] === '1') {
result = result.concat('0');