This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//testing PHP Data Structures (SPL) | |
function displist($s){ | |
echo "<br>"; | |
$s->rewind(); | |
while($s->valid()){ | |
echo $s->current()." "; | |
$s->next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function deckbuilder($gametype){ //custom deck builder function of 20 cards | |
global $dbconnect; | |
$cards=array(); | |
//Build a balanced deck using power distribution | |
if($gametype==3) $pdist=[20,0,0]; //for pokemon cards no distribution | |
else $pdist=[14,5,1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code uses a kind of web scraping to get card images and load it into your filesystem and database | |
//This requires card data to be present in XML format (Cockatrice format works) | |
function copyfile($file_source, $file_target) { | |
$rh = fopen($file_source, "rb"); | |
$wh = fopen($file_target, "wb"); | |
if ($rh===false || $wh===false) { | |
// error reading or opening file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Implementation of generic tree in Python | |
import random | |
import string | |
import pptree | |
class TreeNode(object): | |
"Node of a Tree" | |
def __init__(self, name='root', children=None,parent=None): | |
self.name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Tower of Hanoi (n-disk) algorithm in PHP with Display of Pole Contents | |
//the 3 poles representation | |
$poles=array(array(),array(),array()); | |
function TOH($n,$A="S",$B="I",$C="D"){ | |
if($n>0){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Algorithm implementation to check whether a given location (specified by an address) is within boundaries of a geographical region | |
(region name is also provided as input). | |
This uses Point In Polygon (PIP) algorithm[https://www.npmjs.com/package/@turf/boolean-point-in-polygon] | |
to check coordinate is inside our outside the polygon represented by the GeoJSON data. | |
Author: Shreyak Chakraborty | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for file in `ls -1 /sys/class/drm/*/edid`; do text=$(tr -d '\0' <"$file"); if [ -n "$text" ]; then edid-decode "$file" | grep -e Manufacturer: -e Product; sleep 0.0001; fi done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import( | |
"fmt" | |
) | |
func main(){ | |
arr1 := []int{1,2,3,5} | |
arr2 := []int{1,3,2,5,6,7} | |
found := make(map[int]bool) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import base64 | |
class OneTimePad: | |
def encode_cipher(self,_string, key): | |
key = base64.b64decode(key) | |
retval = [] | |
for k, v in zip(_string, key): | |
retval.append(int(ord(k) ^ v)) | |
return base64.b64encode(bytes(retval)) |