Skip to content

Instantly share code, notes, and snippets.

View kishaningithub's full-sized avatar

Kishan B kishaningithub

View GitHub Profile
var sourceArr = [
{
"article_id": 71942,
"event_code": "A9",
"start_date": "2016-11-25",
"end_date": "2016-12-30",
"quantity_alloted": 120,
"first_delivery_date": "2016-11-25",
"year": 2016,
1.upto(10_000) do |i|
Thread.new { sleep }
puts i
end
#Create user by using following commands
#create user just_cinemas with password 'password123';
#create database just_cinemas;
#GRANT ALL PRIVILEGES ON DATABASE just_cinemas to just_cinemas;
@kishaningithub
kishaningithub / gist:a5260d05a857ef9c4037
Created March 8, 2016 17:29
Optimal trial division
It is not necessary to check all numbers. In fact, the most common algorithm for determining if a number is prime begins at the number 5 (after checking if the number was 2 or 3), and updates by 6 each iteration, and always checks 2 conditions.
So far, it has only been proven that we only need check up the square root of the number we're testing, which is the reason for checking all numbers up to that point. If you're interested, below is a common algorithm for testing for primality.
if(n <= 3)
return n > 1;
else if(n % 2 == 0 || n % 3 == 0)
return false;
@kishaningithub
kishaningithub / BakFileDestroyer.java
Last active August 29, 2015 14:26
Java 8 Code Utils
package com.kishan;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;
public class BakFileDestroyer
{
class ViewController: UIViewController {
var session:AVCaptureSession!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewWillAppear(animated: Bool) {
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your master branch:
http://www.fredonia.edu/faculty/math/JonathanCox/math/SumOfSquares/SumOfSquares.html
@kishaningithub
kishaningithub / Tricks
Last active August 29, 2015 14:15
Competitive programming maths
Is Fibonacci
- Either 5x^2+4 or 5x^2-4 must be a perfect square
No of perfect squares between a and b
- floor(sqrt(b)) - ceil(sqrt(a)) + 1
GCD (Euclid's algorithm) -
p>0 q>0. If q is 0 p is gcd. If not divide p by q
and take the remainder r. The gcd is the gcd(q,r).