{{ message }}

Instantly share code, notes, and snippets.

🎯
Focusing

Shubhanshu Mishranapsternxg

🎯
Focusing
Created Jun 13, 2014
Save current SQL interactive session to file
View saveSQLSession.sh
 mysql --user=root --password=root --tee=./SQLSession.out # To start the logging to the given file from the session use # mysql> \T # Logging to file ./SQLSession.out # To stop logging use # mysql> \t
Created Jun 13, 2014
MySQL: Getting data for histogram plot? Source: http://stackoverflow.com/questions/1764881/mysql-getting-data-for-histogram-plot
View hist.sql
 SELECT ROUND(numeric_value, -2) AS bucket, COUNT(*) AS COUNT, RPAD('', LOG(COUNT(*)), '*') AS bar FROM my_table GROUP BY bucket; /* numeric_value = column name -2 to round in steps of 100. Use -1 for steps of 10 and any positive vale for rounding to nearest decimal LOG(COUNT(*)) is to make the count on log scale
Created Feb 11, 2015
Monte Carlo Method for approximating the value of pi using ratio of area of circle inscribed in unit length square.
View monte_carlo_circle.py
 """ Using Monte Carlo to find the value of pi. Intiution: Ratio of area of circle to area of uniq length squre it is inscribed it can be used to approximate pi. Area of circle = pi/4 Area of square = 1 Ratio = pi/4 Let us generate random points x,y inside the square. The probabilty of the point being inside circle is equal to the above ratio. Circle centered on origin. Given: -0.5 <= x,y <= 0.5 A point is inside circle if x**2 + y**2 <= 1/4
Last active Aug 29, 2015
Generate 10 power range like 1,2,3,..10,20,30,...90,100,200,300...
View gen10power_range.py
 max_n = 1200 [k for k in range(1,max_n) if k % 10**int(np.log10(k)) == 0] """ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000] """ #More computationally effective solution for large max_n
Created Jun 1, 2015
Toy demo for demostrating the implementation of a dictionary in python
View toy_dict.py
 """ This code snippet explains the implementation of a dictionary using a hashing function. Problem: Store the marks of student with given roll numbers in a data structure for quick access of marks based on roll number. Concept: Use a dictionary data structure. """ roll_numbers = [9,8,7,2,1,3,4,5] marks = [10,20,5,13,77,33,2,99] HASH_CONST=11 # Constant used for hashing. For practical purposes more sophesticated and optimized hash functions are used.
Last active Aug 29, 2015
Decrypt the passwords saved by Totroise SVN
View Decrypt.vb
 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' SAMPLE: Encryption and decryption using DPAPI functions. ' ' To run this sample, create a new Visual Basic.NET project using the Console ' Application template and replace the contents of the Module1.vb file with ' the code below. ' ' Go to the folder %APPDATA%\Subversion\auth\svn.simple ' Copy the Encrypted Value of the password denoted by the line below 2 lines below the line saying password ' Compile the code and put this value in a new file called InputFile.txt and in the same location where you are executing the code.
Last active Aug 29, 2015 — forked from shlomibabluki/np_extractor.py
View np_extractor.py
 # coding=UTF-8 import nltk from nltk.corpus import brown # This is a fast and simple noun phrase extractor (based on NLTK) # Feel free to use it, just keep a link back to this post # http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/ # Create by Shlomi Babluki # May, 2013
Last active Aug 29, 2015 — forked from pierre-haessig/logit_scale.ipynb
Logit scale, for plotting cumulated probability distributions (matplotlib implementation). Better visualization of the tails
View logit_scale.ipynb