SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 Re: Off Topic / General Chat » gimp » 2013-06-28 10:53:47

There was a post in Tips, Tricks & Scripts about compiling GIMP 2.9.

Here you go.

#2 Tips, Tricks & Scripts » Automatic Web Login to Network on Boot [BASH Script] » 2013-06-26 21:40:39

Sparkega
Replies: 0

My current residency has available wifi access by a username and password. After connecting to the network, you have to open your browser and login before you can access the full internet. I wanted to find a way to do this automatically on start-up to save myself time.

First I had to do some investigative work on the login website. I fired up my browser and looked through the source for the login command. This is what I found:

<form action="/cgi-bin/login" method="post" autocomplete="off">
    <p class="style11"><span class="style12">USER NAME<br /></span>
        <input  size="32" name="user" type="text" id="user">
    </p>
    <p class="style11"><span class="style12">PASSWORD<br /></span>
        <input type="password" size="32" name="password" id="password">       
        <span class="style8"><br /></span>
    </p>  

    <input type="hidden" name="cmd" value="authenticate" /><br/>     
    <div align="right" id="wwctrl_validity">
        <input type="submit" id="loginBtn" name="login"  value="Login">
    </div>  
</form>

We are able to find the following commands are sent when the login is submitted. The commands are the "name" values on the inputs:

Address: http://login_ip_address/cgi-bin/login
Method: POST
------------Commands Sent------------
-user=_usertextbox_
-password=_passwordtextbox_
-cmd=authenticate
-login=Login

Now we can put it all together to send the POST request using curl with option "-d <data>" for ascii data with commands concatenated with &:

curl -d "user=usernamehere&password=passwordhere&cmd=authenticate&login=Login" http://login_ip_address/cgi-bin/login

Your terminal will then output the response webpage, which hopefully for you is the login successful page. From here we create a BASH script:

#!/bin/bash
curl -d "user=usernamehere&password=passwordhere&cmd=authenticate&login=Login" http://login_ip_address/cgi-bin/login
exit 0

Save it as a .sh file and ensure that you chmod +x the script so it can be executed. I choose to add this script to the end of my Openbox autostart file after sleeping for 15 seconds to ensure my computer was fully booted and the network connection was established:

#Auto network login
(sleep 15s && ~/bin/networkconnect.sh) &

Reboot and verify your connection was made. As an added bonus, I use a VPN so I modified my connection script to automatically connect to my VPN after logging in. I won't go into too many details but here is the modification I made in my networkconnection.sh. The && means the VPN connection will only be made after the curl was completed successfully and I obtained the uuid from nmcli con list:

#!/bin/bash
curl -d "user=usernamehere&password=passwordhere&cmd=authenticate&login=Login" http://login_ip_address/cgi-bin/login && nmcli con up uuid 324587f0-613c-2b87-a124-4f9a97213ddf
exit 0

#3 Re: Tips, Tricks & Scripts » Simple and Fast Multimedia Libary (SFML) 2.0 » 2013-06-08 11:21:35

If you want to use geany to write your code, I made a template file to make writing a new application easier.

{fileheader}

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>

int main(int argc, char **argv)
{
    //constants
    const int windowWidth = 800;
    const int windowHeight = 600;
        
    //SFML Objects
    sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), "Window Title", sf::Style::Close);
    sf::Event event;
    //~ sf::Clock clock;
    
    //main loop
    while (window.isOpen()) {
        //while there are pending events
        while (window.pollEvent(event)) {
            //act on event
            switch (event.type) {
                case sf::Event::Closed:
                    window.close();
                    break;
                //keyboard handling
                case sf::Event::KeyPressed:
                    switch (event.key.code) {
                        case sf::Keyboard::Escape:
                            window.close();
                            break;
                        default:
                            break;
                    }
                    break;
                case sf::Event::KeyReleased:
                    switch (event.key.code) {
                        default:
                            break;
                    }
                    break;
                //mouse handling
                case sf::Event::MouseButtonPressed:
                    switch (event.mouseButton.button) {
                        case sf::Mouse::Left:
                            break;
                        case sf::Mouse::Right:
                            break;
                        default:
                            break;
                    }
                    break;
                case sf::Event::MouseMoved:
                    break;
                //window handling
                case sf::Event::Resized:
                    break;
                case sf::Event::LostFocus:
                    break;
                case sf::Event::GainedFocus:
                    break;
                default:
                    break;
            }//event.type
        }//pollEvent
        
        //TODO: Non-event driven updating
        
        window.clear(sf::Color::Black);
        
        //TODO draw to window buffer (ie window.draw();)
        
        window.display();
    }//IsOpen
	
	return 0;
}

#4 Tips, Tricks & Scripts » Simple and Fast Multimedia Libary (SFML) 2.0 » 2013-06-08 11:18:48

Sparkega
Replies: 1

The Simple and Fast Multimedia Library (SFML) is a multi-platform multimedia library, primarily for c++, that allows you to take in keyboard/mouse input, draw graphics, play sound, and even a networking library is provided. The debian repository has SFML 1.6 available, however SFML 2.0 was officially released about a month ago. I wanted to use the latest version and so I downloaded the latest pre-compiled libraries from http://www.sfml-dev.org/download/sfml/2.0/. [Note: I did not attempt this, but if you are interested in compiling it from the source, here are instructions.]

After extracting the files, they need to be placed into directories recognized by your compiler. I ran "cpp -v" in my terminal to find:

--libdir=/usr/lib

and

#include <...> search starts here:
 /usr/lib/gcc/i486-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.7/include-fixed
 /usr/include/i386-linux-gnu
 /usr/include

I moved all the lib files into the /usr/lib/ directory and include files into /usr/local/include/. The share folder provided in the download has examples and documentation for you also.

SFML depends on the following libraries if you do not have them:

  • pthread

  • opengl

  • xlib

  • xrandr

  • freetype

  • glew

  • jpeg

  • sndfile

  • openal

You can now use the library by including the library files in your c++ files.

Example Code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

Now compile your program with the library files specified (order matters as graphics depends on window which depends on system).

g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system

Example executing: Uef9K5K.png

#5 Introductions » New CrunchBanger » 2013-05-18 19:05:24

Sparkega
Replies: 7

Hello, all. I recently migrated to this Linux flavor last week after using Ubuntu for a couple years. I am finding #! to be very effective and easy to adapt to using. It has been very fast on my laptop. Already have some of my personal configuration setup and ready to use from day-to-day.

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo