Latest Tweets:

*1

Advanced BASH Scripting - Colors!!

I first became intrigued by colorizing BASH when I saw other Linux users customizing their shells with color.

And customizing a PS1 prompt was quite simple. For example, my first PS1 looked something like this.

export PS1="\[\e[00;31m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[00;31m\]\h\[\e[0m\]\[\e[00;37m\]:[\w]\[\e[0m\]"

But if you wanted a custom prompt, the coding for the PS1 and the colors could get confusing. Sometimes I would end up breaking the PS1 because I put a bracket or a semi-colon in the wrong place.

The solution to this was to define the colors separately and then use them in the PS1. Then it was more human-readable. So it would look something like this:

Color_Off='\e[0m'
White='\e[0;37m'
Green='\e[0;32m'
Red='\e[0;31m'
BBlue='\e[1;34m'
BHIWhite='\e[1;97m'
PS1="${debian_chroot:+($debian_chroot)}\[$White\]\d \[$Green\]\t \[$Red\]\u\[$White\]@\[$Red\]\h\[$Color_Off\]\[$BBlue\]:\[$BBlue\]\w \[$BHIWhite\]\$\[$Color_Off\] "

Then customizing the prompt and colors became child’s play. The issue I kept running into was how to find all the colors I could use.

Google helped me supply the initial answer. According to TLDP BASH supports ANSI codes that you can play with to tweak out the colors. These ANSI codes appear quite limited. In most tutorials I found online, the tutorials only touched on using 2 ANSI codes (attribute code, color code), and some touched on using 3 ANSI codes (attribute code, forground color, background color).

But the main hindrance is that no tutorials went beyond that. They all seemed content with stopping at the basics and going no further. In fact the article at TLDP says very specifically “There are no bold background colours.” (NOTE: THIS IS NOT TRUE!!)

Nor did any tutorial mention any other ANSI codes that generated color.

Through all my searching on Google, I was only able to come up with a limited number of ANSI codes. They are as follows:

0 = default colour
1 = bold/intense
4 = underlined
5 = flashing text (but most Terminals don't support blink, and instead just make the text lighter)
7 = reverse (foreground becomes background)
8 = concealed
9 = strikethrough
30 = black 31 = red 32 = green 33 = orange 34 = blue 35 = purple 36 = cyan 37 = grey
40 = black background 41 = red background 42 = green background 43 = orange background 44 = blue background 45 = purple background 46 = cyan background 47 = grey background
90 = dark grey 91 = light red 92 = light green 93 = yellow 94 = light blue 95 = light purple 96 = turquoise
97 = white
100 = dark grey background 101 = light red background 102 = light green background 103 = yellow background 104 = light blue background 105 = light purple background 106 = turquoise background

So for blue text on a gray background, you would use

\e[34;47m

And if you want bold blue text on a gray background, you would use

\e[1;34;47m

The most interesting thing I noticed was that 5 (blinking), didn’t blink in most Terminals, and instead tweaked the color to be a little lighter. The color produced the blink modifier was not usually as bright or intense as 2 (bold/intense) though. So using 5 could open up more color possibilities.

The problem I ran into is that sometimes a code will react differently than expected. For example, Blue text on a white background?

\e[34;37m

would do the trick. But, what about bold blue text on a white background? You might think it was

\e[01;34;37m

but it’s not. In that case, 01 changes the color of the foreground instead of making the text bold. So that makes light blue text on a gray background!

But how to make BOLD blue text on a white background? According to TLDP, it’s impossible. “There are no bold background colors.” And other sites indicate that sometimes it’s sometimes impossible to get bold foreground with certain background colors enabled.

However, this isn’t entirely true…

The trick is to use 07 (reverse) which reverses the foreground and background colors. For example, blue text on a white background? Like I showed above

\e[34;37m

would do the trick but also

\e[07;37;44m

would do it.

Now this can give you a headache when you look at it, but it opens up some more options in colorization. 44 is a blue background color, and 37 gray foreground, but when you put them together with the 07 modifier it reverses the properties so 44 becomes a blue foreground color!

I was puzzling over how to get bold text on a background color. I wanted bold black on gray. It turns out that BASH can support 4+ ANSI codes to define a color! If you thought 3 colors was a headache, this is even more so! But the results are worth it!

It turns out you can keep adding modifiers to tweak the color. So for bold black on gray, you can use

\e[07;01;90;40m

or

\e[01;07;90;40m

But wait!! THERE’S MORE!!

There are even more colors possible! It turns out there is a sweet ANSI spot that contains 256 colors! And that sweet spot is

\e[38;05;{1..256}

Do you want to see all the colors? Open your Terminal and type the following. This will output a amazing color rainbow!

for c in {0..255}
do
echo -e "\e[38;05;${c}m ${c} Moar Colors!!"
done

Now that you know that PS1 and LS_COLORS can support so many ANSI codes, go configure your BASH!

fastcompany:

The partnership could have huge implications in the development of tiny, invisible computers.
Read More>

Where do I have to get in line to get my HUD installed?

fastcompany:

The partnership could have huge implications in the development of tiny, invisible computers.

Read More>

Where do I have to get in line to get my HUD installed?

(via futurescope)

Proxy Glider

Anonymous said: what are the social networking sites that violate privacy ??

Networking is the act of connecting with people to exchange information.

When posting information to a social network, a user probably expects authorized contacts to be able to view it. The simple act of networking presumes that you are giving up the right of total privacy. In order to network, even with close friends in a closed network, you must give up some privacy. Most people expect this, and are willing to give that up. Thus, ALL social networks violate privacy to some extent.

The danger, however, is when social networks allow more information to pass through to the public than the user anticipated. Social networks that provide their services without fees usually make a profit by selling advertising. This is often done through behavioral advertising, also known as targeting. Behavioral advertising is the term used to describe the practice of tailoring advertisements to an individual’s personal interests. Social networks collect lots of information about potential customers and these profiles are repeatedly mined by advertisers trying to create targeted advertisements.

In the end, it is unfair to place blame on any particular social network as a privacy violator because ALL of them are guilty. Yes, undoubtedly, some networks are more or less responsible than others, but this generally a personal choice that must be made by each individual user.

The key to maintaining privacy is:

  1. Don’t post anything online! A good rule of thumb, no matter what the situation, is: “Don’t post anything (even privately) that you wouldn’t be comfortable being public.”
  2. Determine the content control and privacy safeguards of a social network, and choose a network that matches your needs. Don’t join networks just because your friends recommend them. Figure out first whether the network is a good choice for you.
  3. Post anonymously. There are plenty of forums and networks that allow users to post anonymously.

"I must sleep… it’s working… just three more hours…"

Commit message from http://goo.gl/Gzi9t5

"Tweaking leads to twerking. As indeed, does Googling error messages."

Commit log message for http://goo.gl/1PJZeI

mostlysignssomeportents:

I gave a talk last month in Cambridge at the Tedxoxbridge event called How to break the Internet, about how urgent it is that the Internet is fundamentally broken, and why we should be hopeful that we can fix it.

(via futurescope)

Rock-Solid Stable (with Sid)

I’ve been using Crunchbang (also known as #!) for several months now, and for a while it was good. #! was very flexible, but stable. But maybe a bit too stable if that’s possible.

#! uses Debian Wheezy and Crunchbang Waldorf repositories. But when I started looking for packages that I had used on Linux Mint, I couldn’t find the packages. Turns out these packages were in the Debian Jessie repository.

So I would add a line to my sources.list so I could get access to jessie. I would get the package I was looking for, but there were problems. The very next time I ran apt-get upgrade, the new repos would exert their influence on my computer by upgrading practically every package to the highest level. Then my computer would get odd problems, which is what generally follows when you run a not-stable source.

Needless to say, over the past several months, I’ve had plenty of time to experiment. I’ve (intentionally) destroyed a bunch of Crunchbang systems, just so I could put them back together again. And I’ve learned a lot about how to keep #! stable, and yet still permit the use of Jessie and Sid sources.

My first trick involves a process called “pinning”.

So, the first thing I did was add the deb and deb-src lines for both unstable (Jessie) and testing (Sid) to your sources.list at /etc/apt/sources.list. So it will look something like this…

image

Next, I close and save that file.

Now edit /etc/apt/preferences

Generally speaking, Ubuntu and Mint users don’t mess with their preferences files too much. This wasn’t even a trick I learned until I switched over to a rolling Debian release.

The preferences file contains instructions (called pins) that modify the version control settings that APT uses. Specifically, you can use preference pinning to instruct your system to use, optionally use, not use, a particular repo or package. You can instruct your system to freeze a particular repo or package at a level, and not accept upgrades.

What I did was instruct my system to not accept upgrades from any unstable or testing source (leaving me getting upgrades only from stable). So my preferences file looked like this when I was done.

image

As you can see, jessie and sid, testing and unstable, sources are pinned at -10. A pin level less than 0, prevents this source from being used in upgrades.

So now I can have access to those sources, without needing to risk my system becoming unstable in an upgrade.

I know that I’ve succeeded when I can run an apt-get upgrade and apt-get dist-upgrade and have 0 packages needing updates (because only stable is being used for upgrades).

But, I always go one step further…

For my second trick, I go back to my sources.list and I comment out the deb lines for Jessie and Sid, leaving only the deb-src lines open. So, now my sources look like this:

Now I have access to only the sources on Jessie and Sid.

What use is this? Well, firstly, this means that Jessie and Sid will never affect my system stability in an upgrade, because only the deb lines download packages during upgrades. Secondly, this still allows me access to Jessie and Sid, but in a special way… I can compile my own programs and backport them to Wheezy.

For more information on how to backport a package, check out this link: https://wiki.debian.org/DebianUnstable#How_do_I_backport_a_sid_package_to_testing_or_stable.3F

Basically, what you do is:

  1. Download the sources from Sid, and install any needed dependencies from Wheezy repos.
  2. Compile the source for Wheezy.
  3. Install the resulting package.
  4. Voila! You now have an upgraded program on Wheezy, with no dependency problems.

Note: this method of upgrading will not upgrade the resulting program until that particular version trickles down from sid and reaches stable. But, if there is an upgrade, you can always compile and install it again!

Now, I’m enjoying a stable system, and I can still get some bleeding-edge packages from Sid.

fastcompany:

Now that Google is allowing anyone with a cool $1,500 lying around to score themselves a pair of Glass, you’ll probably start seeing a lot more tech geeks wearing headsets in public talking to themselves. Our hands-free, hyper-tethered future is well on its way! So if voice command interfacing is the wave of the future, what good is something seemingly as reductive as an input keyboard?

That was my question—and guessing I wasn’t alone—until I saw Minuum.

Read More>

That is awesome!

(via futurescope)

cypher-neo (Sean Murphy)

I’ve stared at this for about 5 minutes. Time to reblog.

I’ve stared at this for about 5 minutes. Time to reblog.

(Source: jaggoda, via afro-dominicano)

"We live in an age where for ‘art’ to be accepted, the process must often first be glamourized. The truth is that some roles are thankless and art does not exist to be accepted. Art exists simply because it must. It’s not a hype thing. It’s a life thing. As artists, we create because if we didn’t, we’d be dead."

(via ventureandvirtue)

(via katnicholsonart)

Broken Package Header - A Linux Mint Fix

On Linux, things do break sometimes.

On an unstable rolling release like Debian, you can practically expect it. But stable versions like Linux Mint don’t usually break horribly.

However, I’ve encountered a breakage on Linux Mint that took me and everyone I spoke to by surprise. One day, on a new installation, the Update Manager displayed a broken symbol (a shield with a red exclamation mark). When running “sudo apt-get update” in the Terminal, I got this error.

Reading package lists... Error!

E: Encountered a package list with no Package: header

E: Problem with MergeList /var/lib/apt/lists/mirror.umd.edu_ linuxmint_packages_dists_nadia_import_i18n_Translation-en

When I logged into the Linux Mint help chatroom, all the nerds there couldn’t identify this error. One of them told me I must have installed something that conflicted with the system, and I needed to uninstall the offending program.

Except… this was a new install only about 24 hours old.

And then people started giving me the advice no Linux nerd wants to get: you need to start over and reinstall.

So I spent some time figuring out the solution to this problem, and I finally found it. While I don’t know why the package header breaks in the first place, here is the solution to fix it (and it doesn’t involve reinstalling).

Open up two Terminals, side by side. In one of the Terminals, make the error happen again by running:

sudo apt-get update

Once the update completes, you’ll see the error. Keep the Terminal open. The reason to keep it open is so you have a ready reference on exactly what package had the error.

In the other Terminal, navigate to the folder mentioned in the package error message, and show the contents of that folder.

cd /var/lib/apt/lists/

ls

In the /var/lib/apt/lists/ folder the package MergeLists are stored. When you run “sudo apt-get update” the MergeLists in this folder are supposed to be updated and refreshed. Something broke though, and sometimes it can affect more than one MergeList. Since these files are restored on every apt-get update, the easiest way to fix this error is to delete the offending MergeList and then download a new copy of it.

So in the first Terminal that is navigated to /var/lib/apt/lists, I remove a large chunk of the MergeLists that generated the error, like so:

sudo rm mirror.umd.edu_linuxmint_packages*

That removes all the MergeLists that generated the current error. Now go back to the Terminal you ran the update in, and run the update again. This will restore the MergeLists and hopefully fix the problem.

sudo apt-get update

If the update completes with no error, then the problem is fixed. If it generates another error (sometimes this happens because even though multiple errors exist, only one error will display at a time), then go back to the other Terminal and repeat the steps again.

When the updates completes with no error, the problem is fixed and your MergeLists are in order.

Uruguay passes Free Software and Open Format law, in order to “increase security and efficiency of the government”.

There’s a lot of news recently that Microsoft and the NSA are in bed together. So it’s too surprising that governments around the world are leaving Microsoft for other computing alternatives which are safer and probably have less back doors for spies.

Uruguay announced today that they passed a law mandating the use of free software and open formats in government offices whenever possible, in order “to increase the efficiency and security of state.”

Microsoft is finally getting the paycheck for the decades of bad programming with millions of back doors that were specifically engineered into their operating systems.

Now people are turning to FLOSS (Free/Libre Open Source Software) and FOSS (Free Open Source Software). The price tag is much cheaper, usually free. And bugs and holes are patched much faster. And back doors are never tolerated.

1stcomesthefall:

lonelygirrrl:

i’m watching catfish right now and i had to gif this look at these two idiots omg

omg love

ROFLMAO!! That is awesome!

(Source: anklbitrs, via sodelightfullyvague)