Skip to content

Instantly share code, notes, and snippets.

View pinktrink's full-sized avatar

Chloe Kever pinktrink

  • Platonic.Systems
View GitHub Profile
fizzbuzz :: Int -> String
fizzbuzz n
| mod n 3 == 0 && mod n 5 == 0 = "FizzBuzz"
| mod n 3 == 0 = "Fizz"
| mod n 5 == 0 = "Buzz"
| otherwise = show n
main = mapM (print . fizzbuzz) [0..100]
@pinktrink
pinktrink / bash-in-array.sh
Created November 26, 2013 19:22
Determine whether a value exists in an array in Bash. This only works if the array has values which do not have spaces in them.
array=(a b c d e)
search=d
if [[ ' '${array[*]}' ' =~ ' '$search' ' ]]; then
echo 'It exists!'
fi
@pinktrink
pinktrink / obfuscator.py
Created October 26, 2013 23:11
And they said obfuscated Python wasn't possible.
#The point or points of the code hereafter, which obtains the argument given
#before the character which would cause the system to execute the aforementioned
#code (which is also the code hereafter), is to take the aforementioned
#argument, which should be a string of characters that would fit within the
#following regular expression:
#/[[NO, I say, bad jane is unfortunately deceased.\]]+/
#and convert it to an obfuscated JavaScript string that matches the following
#regular expression:
#/.*/
from re import finditer
$.ajax({
dataType: 'jsonp',
jsonp: 'callback',
url: 'http://search.twitter.com/search.json?q=%23fwgangnamstyle',
success: function(obj) {
for (var i = 0, j = obj.results.length; i < j; ++i) {
var user = obj.results[i].from_user;
var tweet_text = obj.results[i].text.replace(/#[\w\d]+/g, "<a href=\"https://twitter.com/$&\" target=\"_blank\">");
var html = "<li><a href=https://twitter.com/" + user + ">@" + user + "</a> said " + tweet_text + "</li>";
console.log(obj.results[i]);
$.ajax({
dataType: 'jsonp',
jsonp: 'callback',
url: 'http://search.twitter.com/search.json?q=%23fwgangnamstyle',
success: function(obj) {
for (var i = 0; i <= obj.results.length - 1; ++i) {
var user = obj.results[i].from_user;
var tweet_text = obj.results[i].text.replace(/#[\w\d]+/g, "<a href=\"https://twitter.com/$&\" target=\"_blank\">");
var html = "<li><a href=https://twitter.com/" + user + ">@" + user + "</a> said " + tweet_text + "</li>";
console.log(obj.results[i]);
$(function(){
$("#tweet-feed").twitterfly({
feeds : [
{
handle : "#FWGangnamStyle"
}
],
tweet_html : '<div><table cellspacing="0" cellpadding="0" border="0" class="tweet-box"><tr><td class="imgcell"><a href="http://twitter.com/{{HANDLE}}" target="_blank"><img src="{{IMAGE}}" alt=""></img></a></td><td><div class="tweet-user"><a href="http://twitter.com/{{HANDLE}}" target="_blank">{{HANDLE}}</a><span> on {{TIME}}</span></div><div class="tweet-text">{{TWEET}}</div></td></tr></table></div>'
});
});
@pinktrink
pinktrink / gist:1050335
Created June 28, 2011 02:02
Validation concept for Contact-Form
<?php
//This is what I'm considering for validation. It should work both in JavaScript and PHP, and should only have to be written out in the configuration.
$validate = array(
'first_name' => 'filled|name|max:64', //Max size of the field can only be 64
'last_name' => 'required|equals:[Jones, James, Smith]|max:64', //'required' is the same as 'filled', and this will only validate if the last name is Jones, James, or Smith.
'middle_name' => 'optional|equals:Danger', //'optional' itself is optional. This will only validate if the middle name is Danger.
'Title' => 'optional|truncate:5' //This will always validate, but if any value is entered that is longer than 5 characters, it will truncate it down to 5 characters.
);