Skip to content

Instantly share code, notes, and snippets.

View santoshtechwiz's full-sized avatar

santosh kumar singh santoshtechwiz

View GitHub Profile
@santoshtechwiz
santoshtechwiz / shell_out.rb
Created April 8, 2017 13:19 — forked from kwilczynski/shell_out.rb
Mixlib::ShellOut live stream reader
# Only for Chef client 11 family!
# Bug was fixed in https://github.com/opscode/chef/commit/d6f6928fd1097709189cd78689e89032d4c9318d
class Chef
module Mixin
module ShellOut
def shell_out(*command_args)
cmd = Mixlib::ShellOut.new(*run_command_compatible_options(command_args))
cmd.live_stream ||= io_for_live_stream
cmd.run_command
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
var width=canvas.width=window.innerWidth;
var height=canvas.height=window.innerHeight;
var n=100;
var xMin=-10;
var xMax=10;
var yMin=-10;
var yMax=10;
window.onload=function(){
@santoshtechwiz
santoshtechwiz / Fractal.js
Last active March 20, 2017 11:56
Fract tree II
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
var width=canvas.width=window.innerWidth;
var diff=Math.PI/6;
height=canvas.height=window.innerHeight;
function line(x1, y1, x2, y2) {
ctx.beginPath();
ctx.strokeStyle='#abcdef';
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
@santoshtechwiz
santoshtechwiz / .js
Created March 19, 2017 14:00
Tree fractal
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var width = canvas.width = window.innerWidth;
var height = canvas.height = window.innerHeight;
var centerX = height / 2;
var diff = Math.PI / 3;
var trunk = 100;
function line(x1, y1, x2, y2) {
ctx.beginPath();
@santoshtechwiz
santoshtechwiz / .js
Last active March 15, 2017 09:33
Maze Generator
var cols, rows;
var w = 5;
var grid = [];
var stack = [];
current = grid[0];
function index(i, j) {
if (i < 0 || j < 0 || i > cols-1 || j > rows-1) {
return -1;
}
return i + j * cols;
@santoshtechwiz
santoshtechwiz / .js
Created March 12, 2017 06:26
Draw Rectangle using line
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
var width=canvas.width=window.innerWidth;
var height=canvas.height=window.innerHeight;
var w=20;
var x=100;
var y=100;
window.onload=function(){
ctx.beginPath();
public class Solution {
private int[][] dp;
public boolean isInterleave(String s1, String s2, String s3) {
if (s1.length() + s2.length() != s3.length()) {
return false;
}
if (s3.length() == 0) {
return true;
}
dp = new int[s1.length()][s2.length()];
@santoshtechwiz
santoshtechwiz / LeetCode-Spiral Matrix II
Created February 12, 2017 09:23 — forked from luoxiaoxun/LeetCode-Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ]
C++:
class Solution {
public:
vector<vector<int> > generateMatrix(int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(n<=0) return vector<vector<int>>();
vector<vector<int>> result(n,vector<int>(n));
int xBeg=0,xEnd=n-1;
int yBeg=0,yEnd=n-1;
@santoshtechwiz
santoshtechwiz / LeetCode-Spiral Matrix II
Created February 12, 2017 09:23 — forked from luoxiaoxun/LeetCode-Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ]
C++:
class Solution {
public:
vector<vector<int> > generateMatrix(int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(n<=0) return vector<vector<int>>();
vector<vector<int>> result(n,vector<int>(n));
int xBeg=0,xEnd=n-1;
int yBeg=0,yEnd=n-1;
@santoshtechwiz
santoshtechwiz / tree_html5.html
Created January 15, 2017 10:14 — forked from gsluthra/tree_html5.html
Fractal Tree Generation using HTML5 Canvas and Random Numbers
<html>
<head>
<script type="text/javascript">
window.onload = draw;
function draw(){