Extract filename and extension in Bash

First, get file name without the path: Alternatively, you can focus on the last ‘/’ of the path instead of the ‘.’ which should work even if you have unpredictable file extensions: You may want to check the documentation : On the web at section “3.5.3 Shell Parameter Expansion“ In the bash manpage at section … Read more

Insert string at specified position

http://php.net/substr_replace In the above snippet, $pos is used in the offset argument of the function. offsetIf offset is non-negative, the replacing will begin at the offset’th offset into string. If offset is negative, the replacing will begin at the offset’th character from the end of string.

Mutable strings in Python

Do you know of a Python library which provides mutable strings? Google returned surprisingly few results. The only usable library I found is http://code.google.com/p/gapbuffer/ which is in C but I would prefer it to be written in pure Python. Edit: Thanks for the responses but I’m after an efficient library. That is, ”.join(list) might work … Read more

Strip HTML from Text JavaScript

If you’re running in a browser, then the easiest way is just to let the browser do it for you… Note: as folks have noted in the comments, this is best avoided if you don’t control the source of the HTML (for example, don’t run this on anything that could’ve come from user input). For … Read more

Insert a string at a specific index

You could prototype your own splice() into String. Polyfill Example Expand snippet EDIT: Modified it to ensure that rem is an absolute value. You could prototype your own splice() into String. Polyfill Example Expand snippet EDIT: Modified it to ensure that rem is an absolute value.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)