Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
lbvf50mobile / example.md
Created May 19, 2018 06:13 — forked from moreati/example.md
Read and Execute permissions on Linux directories, by example

Preperation

Create 3 top-level directories. Create a file and a directory in each.

$ mkdir r rx x
$ touch {r,rx,x}/file
$ mkdir {r,rx,x}/dir
@lbvf50mobile
lbvf50mobile / README.md
Created May 31, 2018 14:07 — forked from a-know/README.md
Get and Show cell's value from Google Spreadsheet Widget for Dashing

Description

Get and Show cell's value from Google Spreadsheet Widget for Dashing.

Dependency

  • gem 'google-api-client'
  • gem 'google_drive'

Installation

dashing install e0ad37c2e137d2da0916

@lbvf50mobile
lbvf50mobile / simple_args_parsing.sh
Created June 16, 2018 11:06 — forked from jehiah/simple_args_parsing.sh
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@lbvf50mobile
lbvf50mobile / parse-options.sh
Created June 20, 2018 17:47 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@lbvf50mobile
lbvf50mobile / pdf2txt.rb
Created July 21, 2018 05:17 — forked from emad-elsaid/pdf2txt.rb
PDF to Text converter using ruby
#!/usr/bin/env ruby
require 'pdf/reader' # gem install pdf-reader
# credits to :
# https://github.com/yob/pdf-reader/blob/master/examples/text.rb
# usage example:
# ruby pdf2txt.rb /path-to-file/file1.pdf [/path-to-file/file2.pdf..]
ARGV.each do |filename|
PDF::Reader.open(filename) do |reader|
/* Deleting a node from Binary search tree */
#include<iostream>
using namespace std;
struct Node {
int data;
struct Node *left;
struct Node *right;
};
//Function to find minimum in a tree.
Node* FindMin(Node* root)
@lbvf50mobile
lbvf50mobile / bst-delete-node.js
Created September 4, 2018 20:38 — forked from primaryobjects/bst-delete-node.js
Delete a node in a Binary Search Tree BST.
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root
* @param {number} key
@lbvf50mobile
lbvf50mobile / benchmark_building_a_hash.rb
Created October 27, 2018 16:13 — forked from jonatack/benchmark_building_a_hash.rb
Benchmark building a Ruby hash: #each - #each_with_object - #reduce - Hash[map] - #map.zip(map).to_h - #reduce-merge
require 'benchmark/ips'
Benchmark.ips do |x|
Property = Struct.new(:name, :original_name)
PROPERTIES = [
Property.new("Clo", "Chloe" ),
Property.new("Jon", "Jonathan" ),
Property.new("Kris", "Kristin" ),
@lbvf50mobile
lbvf50mobile / yaml.rb
Created December 12, 2018 12:41 — forked from ammaaim/yaml.rb
Read/Write YAML in Ruby
require 'yaml'
$db_file = 'filename.yaml'
def load_data
text = File.read 'db.yaml'
return YAML.load text
end
def store_data hash
@lbvf50mobile
lbvf50mobile / 1. sinatra-basic-with-comments.rb
Created December 31, 2018 11:44 — forked from Integralist/1. sinatra-basic-with-comments.rb
Create basic site using Ruby and Sinatra (and external templates)
#!/usr/bin/env ruby
=begin
install Sinatra: gem install sinatra
install Shotgun: gem install shotgun (this auto-reloads sinatra on every http request - which means every time you make a change in your code you don't have to stop then start sinatra)
To just run your code using Sinatra: ruby name-of-file.rb
To run your code using Shotgun (which is just Sinatra but with ability to auto-reload when changes are made to files): shotgun name-of-file.rb
The following examples are run using Shotgun and the URL is: http://127.0.0.1:9393/