Skip to content

Instantly share code, notes, and snippets.

View OsandaMalith's full-sized avatar

Osanda Malith Jayathissa OsandaMalith

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#define MAX 65535
// https://github.com/OsandaMalith
void banner() {
static const char *banner =
#include <windows.h>
#include <stdio.h>
#define BUF_SIZE 8192
// http://osandamalith.wordpress.com
int main(int argc, LPTSTR argv[])
{
HANDLE hIn, hOut;
DWORD nIn, nOut;
CHAR buffer[BUF_SIZE];
if (argc != 3) {
@OsandaMalith
OsandaMalith / BlueBook.py
Created May 30, 2015 17:50
Ex Machina Easter Egg ;)
#BlueBook code decryption
import sys
def sieve(n):
x = [1] * n
x[1] = 0
for i in range(2,n/2):
j = 2 * i
while j < n:
x[j]=0
@OsandaMalith
OsandaMalith / plugins.js
Last active August 29, 2015 14:22
Displays all the installed browser plugin along with the file names. Tested on Chrome and Firefox.
// Paste this in the JS Console - Tested with Chrome and Firefox
for(i = 0; i < navigator.plugins.length; i++) console.log(navigator.plugins[i].name + ' :: ' + navigator.plugins[i].filename);
// Printing as HTML - works only with Chrome
for(i = 0; i < navigator.plugins.length; i++) document.write(navigator.plugins[i].name + ' :: ' + navigator.plugins[i].filename + '<br>');
@OsandaMalith
OsandaMalith / .gdbinit
Last active October 6, 2015 06:24
Flags util (for .gdbinit)
# Flags util (for .gdbinit)
# set of commands for easy manipulation on FLAGS
# CC-BY: hasherezade
# Modified by: @OsandaMalith
# Added options for setting and unsetting flags
define translate_flag
if $argc == 0
help translate_flag
else
#!/usr/bin/env python2.7
# A 8x8 Chessboard coded for fun
# @OsandaMalith
##
# main
##
if __name__ == "__main__":
for i in range(1,9):
for j in range(1,9):
@OsandaMalith
OsandaMalith / Point.java
Last active August 29, 2015 14:25
Calculate Perimeter, Area and checks for square based on X and Y cordinates
package SRectangle;
// CC-BY : Osanda Malith Jayathissa
public class Point {
private int x, y;
public Point(int x, int y) {
this.x=(x);
this.y=(y);
}
public int getX() {
@OsandaMalith
OsandaMalith / nonkill.au3
Last active October 18, 2019 13:48
Non killable process due to signedness error in nt!NtSetInformationProcess
sNonKillableProcess('notepad.exe')
Func sNonKillableProcess($sProcess)
Local $sProcessHandle , $sPid , $sAccess , $sSignedvalue , $ProcessIoPriority , $sProcessInformationLength , $sStruct
If Not @Compiled Then Exit
@OsandaMalith
OsandaMalith / Company.java
Last active August 27, 2020 14:27
Java 2D arrays
// CC-BY : Osanda Malith Jayathissa (@OsandaMalith)
public class Company {
// member variables
private double[][] sales;
private int salesPerson;
private int product;
private double value;
public Company() {
this.sales = new double[4][5];
import java.util.Random;
public class dice {
// Codded by Osanda Malith Jayathissa (@OsandaMalith)
/*
Write a program that simulates the rolling of two dice. The program should use rand to roll the first die and should use rand again to roll the second die. The sum of two values should then be calculated. [Note : Each die can show an integer value from 1 to 6, so the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the least frequent sums.] Note that there are 36 possible combinations of the two dice. Your program should roll the two dice 3,600 times. Use a one_dimensional array to tally the numbers of times each possible sum appears. Print the results in a tabular format. Also, determine if the totals are reasonable (i.e., there are six ways to roll a 7, so approximately one-sixth of all the rolls should be 7).
http://www.freemathhelp.com/rolling-dice.html
Outcome List of Combinations Total
2 1+1 1
3 1+2, 2+1 2