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
require 'net/ssh' | |
require 'optparse' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: ruby permission.rb [-h some-host-option -a lock -u garion]" | |
%i{host user action}.each do |option| | |
opts.on("-#{option[0]}VALUE", "--#{option}=VALUE") do |value| |
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
# This class is solely used for extracting arguments from a string | |
# It is used to process the arguments input to template_methods in the CMS content areas | |
# It handles arguments that are comma separated, inside or outside of quotes | |
# Like normal arguments to a programming function if something is inside a quote it will | |
# all be part of the same argument and commas inside of quotes are part of that argument | |
# rather than used to separate it from another argument. It also takes into account backslashes | |
# so 'I\'m an argument' will properly be processed | |
# | |
# For example link("http://google.com", 'Google is fun to use, really it is') | |
# It will result in the arguments: |
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 forceDownload() | |
{ | |
$file_name = "/some/directory/not/publicly/available/" . $_GET['file']; | |
$file = file_get_contents( $file_name ); | |
if( !empty($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
-module(numbers). | |
-export([fib/1, triangle_numbers/1, triangle_number/1, bsearch/2, pair_sum/2]). | |
fib(1)-> | |
[0]; | |
fib(2)-> | |
[0,1]; | |
fib(N)-> | |
PrevFibs = fib(N-1), | |
lists:append(PrevFibs, [ lists:nth(length(PrevFibs) - 1, PrevFibs) + lists:last(PrevFibs) ] ). |
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
-module(fibonacci). | |
-export([process/1]). | |
process(1) -> | |
[0]; | |
process(2) -> | |
[0,1]; | |
process(N) -> | |
lists:append(process(N - 1), [ lists:last(process(N - 1)) + lists:last(process(N - 2) ) ] ). |
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
def translate( words ) | |
words.translate | |
end | |
class String | |
def grab_punctuation | |
punctuation = '' | |
if !self[-1].match(/[a-z]/i) | |
punctuation = self[-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
def pig_latinize_word( word ) | |
parts = word.split(/\b([^a,e,i,o,u]{0,}qu|[^a,e,i,o,u]+)?([a,e,i,o,u][a-z]{0,})?/i) #https://regex101.com/r/yP8yF9/3 <-- this is where I worked out the regex | |
parts.shift if parts.first.empty? #getting rid of that first empty element that results from the regex matching the entire word, adding the conditional just in case there are outliers where the first word is not blank that I haven't thought of | |
parts << parts.shift #moving the first element to be the last element | |
"#{parts.join('')}ay" | |
end | |
def translate( words ) | |
( words.split(' ').inject([]) {|pig_latinized_words,word| pig_latinized_words << pig_latinize_word( word )} ).join(' ') #did it all in one line because I was curious if Ruby would let me, it just splits the words up by spaces, makes a new array of the pig latinized words, and then joins them back with spaces | |
end |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<div ng-app="app" ng-controller="myAppController"> | |
<h3>Items</h3> | |
<ul> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<h3>Items</h3> | |
<ul class="display_items"></ul> | |
<hr> |
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
<h2>Original: </h2> | |
<div id="original">http://0e24f87c32490a111f93f3579380e24d7f3579f.0e24f87c32490a1117f3579380e24f87c32490a111a3d7f3579f.0e24f87c32490a111f.0e24f87c32490a111f937ffffa3.0e24f82490af111f9f373d7f3579380e24f87c2490a111f937a3d7f3579f.tdneffsdsafstor.sometdhing.smarffffftmefsmbffff.com.uk/whaffdffffffffffffffffffsadffdsarg+whatev?he=that http://google.com/somewhere toddnestor.com yourmom.com google.com http://google.com somewhere.so whatever.sow.u whatever.sow.uk wow.wo https:something.com https://something.com //solid.online <img src="http://google.com" /> toddnestor.com, toddnestor.com. toddnestor.com: toddnestor.com? toddnestor.com!</div> | |
<h2>Linkified: </h2> | |
<div id="linkified"></div> | |
<script> | |
var linkify = function( string ) { | |
var re = /(?:^|\ )(((?:(?:http(?:s)?\:)?(?:\/\/))|(?:\/\/))?(?:(?=[a-z0-9\-\.]{1,255}(?=\/|\ |$|\:|\?|\,|\!))(?:(?:(?:[a-z0-9]{1}(?:[a-z0-9\-]{1,62})?\.){1,127})[a-z]{2,}(?:\.[a-z]{2})?))(?:[a-z0-9\/\-\_\%\?\&\!\$\'\,\(\)\*\+\=\;])*?)(?=$|\.(?=\ |$)|\:|\ |\?(?=\ |$) |
NewerOlder