Author Topic: post random lines of code here  (Read 4744 times)


While(true) { }

Am I 1337 yet?

print("Hello, world!");


Code: (php) [Select]
function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

~F2::
clipboard = %clipboard%
send %clipboard% {enter}

using System.IO

Streamwriter outputFile;

outputFile = CreateText("hue.txt");

outputFile.WriteLine("so edgy");
outputFile.Writeline("git on my level");

outputFile.Close();

/edit

crap forgot the using System.IO part
« Last Edit: January 04, 2015, 05:14:28 PM by SetGaming »



At the moment, this only spawns two blocks side by side. Lot of code work to do today.

Code: [Select]
Conductor = {
timingWindow = 0.1,

created = function(self, folderName)
local songfolder = 'songs/' .. folderName
local songfile = songfolder .. '/song.lua'
if not love.filesystem.exists(songfile) then
error('"' .. songfolder .. '" does not have a song.lua.')
end

-- TODO: make song loading a little safer
local songdata = love.filesystem.load(songfile)()

self.songdata = songdata
self.time = 0
self.beat = -songdata.offset * self:beatsPerSecond()
self.playing = false
self.beatsPerGroup = songdata.beatsPerGroup

-- sort the notes table by beat
table.sort(songdata.notes, function(a, b)
return a[1] < b[1]
end)

-- convert the note tables into a more usable format
-- ex: { 1, 'click' }
-- note.beat = first element
-- note.type = second element
-- note.info = array of whatever else is in the table
-- note.time = time of the note in seconds
-- note.next = the note that comes after this one (nil if it's the last)

for i,note in pairs(songdata.notes) do
note.beat = table.remove(note, 1)
note.type = table.remove(note, 1)
note.info = { unpack(note) }

note.time = songdata.offset + note.beat * self:secondsPerBeat()
note.next = songdata.notes[i + 1]
end

self.beatTimer = create(Timer, self:secondsPerBeat())
self.beatTimer.time = -(self.songdata.offset % self:secondsPerBeat()) + self:secondsPerBeat()

local sourcepath = songfolder .. '/' .. songdata.source
self.source = love.audio.newSource(sourcepath, 'stream')
end,

onBeat = function(self, fn)
self.beatTimer:addCallback(fn)
end,

play = function(self)
self.playing = true
self.source:play()
self.source:seek(self.time)
end,

pause = function(self)
self.playing = false
self.source:pause()
end,

stop = function(self)
self.playing = false
self.source:stop()
self.time = 0
end,

update = function(self, dt)
if self.playing then
self.time = self.time + dt
self.beat = self.beat + self:beatsPerSecond() * dt
end

local bpmChanges = self.songdata.bpmChanges
if bpmChanges then
for i=#bpmChanges, 1, -1 do
local change = bpmChanges[i]
if self.beat > change[1] then
self.songdata.bpm = change[2]
break
end
end
end

self.beatTimer:update(dt)
end,

secondsPerBeat = function(self)
return 60 / self.songdata.bpm
end,

beatsPerSecond = function(self)
return self.songdata.bpm / 60
end,
}

The conductor class in my rhythm game. Not sure how long is too long, though.


}how do I code
http://scratch.mit.edu/

Really good place to start. If you wait a bit, you can also sign up (FOR FREE!) to the Harvard Computer Science course, which is a programming course.

http://scratch.mit.edu/

Really good place to start. If you wait a bit, you can also sign up (FOR FREE!) to the Harvard Computer Science course, which is a programming course.

I second this.

Just the middle of some projects.

Code: [Select]
var chatStyle = document.createElement("style");
chatStyle.innerHTML = "#messageBox:focus { border: 2px solid #6B8FB2;border-bottom: 2px solid #DBFFFF;border-right: 2px solid #DBFFFF; }";

document.head.appendChild(chatStyle);

var chatbox = document.createElement("div");
chatbox.id = "chatDiv";
chatbox.innerHTML = '<table cellspacing="0" cellpadding="10" border="0" align="center" style="table-layout:fixed;" width="95%"><tbody><tr><td valign="top" style="background-color: #ffffff;"><table border="0" width="100%" cellspacing="0" cellpadding="4" style="border: 1px solid #000; border-bottom: 0px;"><tbody><tr class="titlebg"><td width="100%" colspan="1">Chatbox</td></tr></tbody></table><table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor" style="table-layout:fixed;"><tbody><tr class="windowbg2"><td><div id="chatZone" style=" word-wrap: break-word; width: 100%; height: 150px;"></div></td><td width="150px"><div id="whosOnline" style=" word-wrap: break-word; width: 100%;  overflow-y: scroll; height: 150px;"></div></td></tr></tbody></table><table border="0" width="100%" cellspacing="0" cellpadding="4" style="border: 1px solid #000; border-top: 0px;"><tbody><tr class="windowbg2"><td colspan="1"><input type="text" id="messageBox" style="outline: none; width: 100%;" /></td><td width="50px"> <input type="button" id="sendBtn" value="Send"/></td></tr></tbody></table></td></tr></tbody></table>';


var imgs = document.getElementsByTagName('img');

for(i = 0; i < imgs.length; i++) {
    if(imgs[i].getAttribute("alt") == "Logout") {
        imgs[i].parentNode.parentNode.parentNode.insertBefore(chatbox, imgs[i].parentNode.parentNode.nextSibling);
    }
}

var whosOnline = document.getElementById("whosOnline");
var messageBox = document.getElementById("messageBox");

var lastHTML = '';

function update() {
    GM_xmlhttpRequest({
        method: "GET",
        url: webserver + "index.php",
        onload: function(response) {
            if(response.responseText != lastHTML) {
                chatZone.innerHTML = response.responseText;
                lastHTML = response.responseText;
            }
        }
    });
}

function getRecent() {
    GM_xmlhttpRequest({
        method: "GET",
        url: webserver + "index.php?recent",
        onload: function(response) {
            whosOnline.innerHTML = response.responseText;
        }
    });
}

also some C# I was fiddling with on my desktop

Code: [Select]
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Timers;
using System.Windows.Forms;

class Program
{
static PictureBox pictureBox = new PictureBox();
static System.Timers.Timer timer1;

static void Main(string[] args)
{

//var pictureBox = new PictureBox();

var form = new Form {  };
form.Width = 700;
form.Height = 500;
form.Text = "NIGS";
pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox.Dock = DockStyle.Top;
pictureBox.Width = form.Width;
pictureBox.Height = form.Height - 50;

var button1 = new Button();
button1.Dock = DockStyle.Bottom;
button1.Width = form.Width;
button1.Height = 50;
button1.Text = "Capture";
button1.Click += new EventHandler(button1_Click);
form.Controls.Add(button1);
form.Controls.Add(pictureBox);

Application.Run(form);
}

static void button1_Click(object sender, EventArgs e) {
timer1 = new System.Timers.Timer(100);
timer1.Elapsed += new ElapsedEventHandler(timer1_Elapsed);
timer1.Enabled = true;
}

static void captureDesktop() {
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);

var gfxScreenshot = Graphics.FromImage(bmpScreenshot);

gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0,
0,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);

pictureBox.Image = bmpScreenshot;

}

static void timer1_Elapsed(object sender, ElapsedEventArgs e) {
captureDesktop();
}
}

and some PHP

Code: [Select]
foreach($sorted as $cur) {
if($cur != 'index.php' and $cur != '.' and $cur != '..') {
} else {
if(($key = array_search($cur, $sorted)) !== false) {
unset($sorted[$key]);
}
}
}

$max = 20;

$curPage = 1;
if(isset($_GET['page'])) {
$curPage = $_GET['page'];
}
$curPage = $curPage - 1;

$pages = ceil(sizeof($sorted) / $max);

if($curPage + 1<= $pages) {
$sorted = array_chunk($sorted,$max)[$curPage];
} else {
$sorted = array_chunk($sorted,$max)[$pages - 1];
}



foreach($sorted as $cur) {
if($cur != 'index.php' and $cur != '.' and $cur != '..') {
$pureId = explode('.',$cur)[0];
$content = file_get_contents($dir.$cur);
$content2 = str_replace("\n",'<br/>',$content);
$rating = 0;
$ratingArray = array();
if(file_exists($rep.$cur)) {
$ratingArray = json_decode(file_get_contents($rep.$cur),true);
foreach($ratingArray as $cur) {
if($cur == 1) {
$rating += 1;
} else if($cur == 0) {
$rating -= 1;
}
}
« Last Edit: January 04, 2015, 05:44:43 PM by Steve5451² »

Have a useless fakemail php script I wrote a long time ago.

Code: [Select]
<?php
//This is now just released as source because having this on my website is a pretty extreme vulnerability. I did say that I would only host it for about an hour, didn't I?
if($_POST[from] == null || $_POST[to] == null)
{
print("
Fake mailer!<br>
<form method=\"post\">
Sender address: <input type=\"from\" name=\"from\"><br>
Recipient: <input type=\"to\" name=\"to\"><br>
The formatting of these must comply with RFC 2822. Some examples are: \"user@example.com\" \"user@example.com, anotheruser@example.com\" \"User &lt;user@example.com&gt;\" \"User &lt;user@example.com&gt;, Another User &lt;anotheruser@example.com&gt;\"<br>
Subject: <input type=\"sub\" name=\"sub\"><br>
Text: <textarea type=\"text\" name=\"text\" width=500></textarea><br>
<INPUT type=\"submit\" value=\"Send\">
</form><br>
"
);
}

else
{
$headers "From: " $_POST[from] . "\r\n" .
"Reply-To:" $_POST[from] . "\r\n" .
'X-Mailer: PHP/' phpversion();

$message wordwrap($_POST[text], 70"\r\n");

$success mail($_POST[to], $_POST[sub], $message$headers);

if($success)
print("Message sent!");
else
print("Message wasn't sent for some reason.");
}
?>


Steve please, add a newline in that html line.
« Last Edit: January 04, 2015, 05:48:18 PM by Pecon »

So for those who are not yet comfortable with programming, I highly recommend taking this course:

https://www.edx.org/course/introduction-computer-science-harvardx-cs50x#.VKnC0Xsabao

Select "Enroll", and then choose "Honors Student". You can always pay for the certificate later, or if get it for free if your marks are high enough.

Good luck, those who enroll :)

yay now I can put myself into student debt before college :D