This file contains hidden or 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 React, { Component } from 'react'; | |
| export class Mouse extends React.Component { | |
| state = { x: 0, y: 0 }; | |
| onMouseMove = (event) => { | |
| this.setState( | |
| { x: event.clientX, y: event.clientY } | |
| ); | |
| }; |
This file contains hidden or 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
| #!bin/bash | |
| HELPTEXT=`cat <<EOF | |
| This script will neatly package your java project. | |
| Recommended Project Structure | |
| .. compile_run.sh bin lib src | |
| Options: | |
| -t|--target [string] the fully qualified name of the main class | |
| -s|--standalone [flag] compile all dependencies into the final jar |
This file contains hidden or 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
| #!/bin/bash | |
| # script for cloning repos from org | |
| # and setting up remotes | |
| # must have existing fork of target repo | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: clone_repo.sh <git username> <repository name>" | |
| else | |
| git clone https://www.github.com/"$1"/"$2".git "$2" |
This file contains hidden or 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
| ## ATTN: run in ELEVETED powershell OR run as ADMINISTRATOR | |
| ## C:>\ powershell.exe | |
| ## PS C:>\ .\gen_machine_key.ps1 | |
| ## copy output into your web.config > <system.web> | |
| # Generates a <machineKey> element that can be copied + pasted into a Web.config file. | |
| function Generate-MachineKey { | |
| [CmdletBinding()] | |
| param ( | |
| [ValidateSet("AES", "DES", "3DES")] |
This file contains hidden or 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
| function median($arr){ | |
| if($arr){ | |
| $count = count($arr); | |
| sort($arr); | |
| $mid = floor($count/2); | |
| return ($arr[$mid]+$arr[$mid+1-$count%2])/2; | |
| } | |
| return false; | |
| } | |
| function average($arr){ |
This file contains hidden or 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
| #!/bin/bash | |
| let count0=0 | |
| for f in $(ls ./tests/*.txt); do | |
| ./a.out 0 < $f > ./tests/`basename $f .txt`.output; | |
| diff -Bw ./tests/`basename $f .txt`.output ${f}.expected > ./tests/`basename $f .txt`.diff; | |
| done; | |
| for f in $(ls tests/*.txt); do | |
| echo "========================================================"; |
This file contains hidden or 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
| def maxProfit ( self, prices ): | |
| previous_delta = 0 | |
| delta = 0 | |
| max_profit = 0 | |
| for i in range( 1 , len ( prices ) ) : | |
| previous_delta = delta | |
| delta = prices[ i ] - prices [ i - 1 ] |
This file contains hidden or 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
| int maxProfit(int* prices, int n) { | |
| int previous_delta = 0; | |
| int delta = 0; | |
| int max_profit = 0; | |
| for ( int i = 1 ; i < n ; i ++ ) | |
| { | |
| previous_delta = delta; | |
| delta = prices[ i ] - prices [ i - 1 ]; |
This file contains hidden or 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
| WHILE no swaps performed | |
| FOR pair of elements | |
| IF pair is out of order | |
| swap pair |
This file contains hidden or 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
| //************************************************************************// | |
| // one_var_bubble_sort.c // | |
| //************************************************************************// | |
| // | |
| // AUTHOR: Patrick Michaelsen | |
| // EMAIL: [email protected] | |
| // [email protected] | |
| // WEBSITE: PatrickMichaelsen.com | |
| // | |
| // DESCRIPTION: This algorithm bubble sorts an array of |