// use a function for the exact format desired...
function MDYDateString(d){
function pad(n){
return n< 10? '0'+ n: n;
}
return pad(d.getUTCMonth()+ 1)+ '/'+ pad(d.getUTCDate())+ '/'+ d.getUTCFullYear();
}
// prints something like 12/20/2012
var d= new Date();
console.log(MDYDateString(d));
JavaScript - check starts with and ends with | test startsWith and endsWith
Add this functions to the String prototype:
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str){
return this.slice(0, str.length) == str;
};
}
if (typeof String.prototype.endsWith != 'function') {
String.prototype.endsWith = function (str){
return this.slice(-str.length) == str;
};
}
Then use it:"Starts with JavaScript".startsWith("Starts"); // true
var foo= "Ends with JavaScript";
var bar= "JavaScript";
foo.startsWith(bar); // true
UnRar - extract files from rar archives | BackTrack 5
apt-get install unrar
unrar x file.rar path/
unrar --help
unrar x file.rar path/
unrar --help
MySQL - ERROR 2002 (HY000): Can't connect to local MySQL server through socket | BackTrack 5
mysql -u root -p
****
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
mkdir /var/run/mysqld
touch /var/run/mysqld/mysqld.sock
****
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
mkdir /var/run/mysqld
touch /var/run/mysqld/mysqld.sock
chown -R mysql /var/run/mysqld
/etc/init.d/mysql restart
Google Chrome can not be run as root - BackTrack 5
Google Chrome can not be run as root.
1. Open Konsole Terminal
2. Type
3. Press Tab -> Switch to ASCII
4. Press Ctrl+ S -> Search "geteuid"
Modify to "getppid"
5. Press Ctrl+ X -> Save
Please start Google Chrome as a normal user. To run as root, you must specify an alternate --user-data-dir for storage of profile information.
1. Open Konsole Terminal
2. Type
cd /opt/google/chrome/
hexedit chrome
3. Press Tab -> Switch to ASCII
4. Press Ctrl+ S -> Search "geteuid"
Modify to "getppid"
5. Press Ctrl+ X -> Save
Install Flash Player - BackTrack 5
- As you may have noticed Flash Player does not work on Backtrack 5, so in order to fix this we first need to remove the current flash player by issuing the following commands:
root@bt:~# apt-get purge flashplugin-nonfree flashplugin-installer gnash gnash-common mozilla-plugin-gnash swfdec-mozilla root@bt:~# rm -f /usr/lib/firefox/plugins/*flash* root@bt:~# rm -f /usr/lib/firefox-addons/plugins/*flash* root@bt:~# rm -f /usr/lib/mozilla/plugins/*flash* root@bt:~# rm -f ~/.mozilla/plugins/*flash*so root@bt:~# rm -rfd /usr/lib/nspluginwrapper
- After removing flash we need to get the new flash player from the official website:
- Flash x64 ONLY FOR x64.
- Flash Player Download the .tar.gz file.
- We will begin with Flash Square, SKIP THIS if you aren't using an x64 version of BackTrack.
root@bt:~# tar xvfz flashplayer10_2_p3_64bit_linux_111710.tar.gz root@bt:~# chown root:root libflashplayer.so root@bt:~# chmod 644 libflashplayer.so root@bt:~# cp -f libflashplayer.so /usr/lib/mozilla/plugins/ root@bt:~# rm -rf libflashplayer.so root@bt:~# ln -s /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox/plugins/
- Next up we will take care of the Flash Player:
root@bt:~# tar xvfz install_flash_player_10_linux.tar.gz root@bt:~# mkdir ~/.mozilla/plugins root@bt:~# mv -f libflashplayer.so ~/.mozilla/plugins/ root@bt:~# ln -s /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/ root@bt:~# ln -s /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/xulrunner-addons/plugins/
- We can test if flash player works over here.
Extract tar gz files (.tar.gz) - Linux command
Extract the vtigercrm-5.4.0.tar.gz archive file to /var/www/
More:
tar xvfz vtigercrm-5.4.0.tar.gz -C /var/www/
More:
man tar
Top 1000 SQL Performance Tips - Top10SQLPerformanceTips
Interactive session from MySQL Camp I:
Specific Query Performance Tips (see also database design tips for tips on indexes):
Specific Query Performance Tips (see also database design tips for tips on indexes):
- Use EXPLAIN to profile the query execution plan
- Use Slow Query Log (always have it on!)
- Don't use DISTINCT when you have or could use GROUP BY
- Insert performance
- Batch INSERT and REPLACE
- Use LOAD DATA instead of INSERT
- LIMIT m,n may not be as fast as it sounds. Learn how to improve it and read more about Efficient Pagination Using MySQL
- Don't use ORDER BY RAND() if you have > ~2K records
- Use SQL_NO_CACHE when you are SELECTing frequently updated data or large sets of data
- Avoid wildcards at the start of LIKE queries
- Avoid correlated subqueries and in select and where clause (try to avoid in)
- No calculated comparisons -- isolate indexed columns
- ORDER BY and LIMIT work best with equalities and covered indexes
- Separate text/blobs from metadata, don't put text/blobs in results if you don't need them
- Derived tables (subqueries in the FROM clause) can be useful for retrieving BLOBs without sorting them. (Self-join can speed up a query if 1st part finds the IDs and uses then to fetch the rest)
- ALTER TABLE...ORDER BY can take data sorted chronologically and re-order it by a different field -- this can make queries on that field run faster (maybe this goes in indexing?)
- Know when to split a complex query and join smaller ones
- Delete small amounts at a time if you can
- Make similar queries consistent so cache is used
- Have good SQL query standards
- Don't use deprecated features
- Turning OR on multiple index fields (<5.0) into UNION may speed things up (with LIMIT), after 5.0 the index_merge should pick stuff up.
- Don't use COUNT * on Innodb tables for every search, do it a few times and/or summary tables, or if you need it for the total # of rows, use SQL_CALC_FOUND_ROWS and SELECT FOUND_ROWS()
- Use INSERT ... ON DUPLICATE KEY update (INSERT IGNORE) to avoid having to SELECT
- use groupwise maximum instead of subqueries
- Avoid using IN(...) when selecting on indexed fields, It will kill the performance of SELECT query.
- Prefer using UNION ALL if you don't need to merge the result
- Use benchmarking
- isolate workloads don't let administrative work interfere with customer performance. (ie backups)
- Debugging sucks, testing rocks!
- As your data grows, indexing may change (cardinality and selectivity change). Structuring may want to change. Make your schema as modular as your code. Make your code able to scale. Plan and embrace change, and get developers to do the same.
- Minimize traffic by fetching only what you need.
- Paging/chunked data retrieval to limit
- Don't use SELECT *
- Be wary of lots of small quick queries if a longer query can be more efficient
- Use multi_query if appropriate to reduce round-trips
- Use stored procedures to avoid bandwidth wastage
- Use proper data partitions
- For Cluster. Start thinking about Cluster *before* you need them
- Keep the database host as clean as possible. Do you really need a windowing system on that server?
- Utilize the strengths of the OS
- pare down cron scripts
- create a test environment
- source control schema and config files
- for LVM innodb backups, restore to a different instance of MySQL so Innodb can roll forward
- partition appropriately
- partition your database when you have real data -- do not assume you know your dataset until you have real data
- Reduce swappiness of your OS
- innodb_flush_commit=0 can help slave lag
- Optimize for data types, use consistent data types. Use PROCEDURE ANALYSE() to help determine the smallest data type for your needs.
- use optimistic locking, not pessimistic locking. try to use shared lock, not exclusive lock. share mode vs. FOR UPDATE
- if you can, compress text/blobs
- compress static data
- don't back up static data as often
- enable and increase the query and buffer caches if appropriate
- config params -- http://docs.cellblue.nl/2007/03/17/easy-mysql-performance-tweaks/ is a good reference
- Config variables & tips:
- use one of the supplied config files
- key_buffer, unix cache (leave some RAM free), per-connection variables, innodb memory variables
- be aware of global vs. per-connection variables
- check SHOW STATUS and SHOW VARIABLES (GLOBAL|SESSION in 5.0 and up)
- be aware of swapping esp. with Linux, "swappiness" (bypass OS filecache for innodb data files, innodb_flush_method=O_DIRECT if possible (this is also OS specific))
- defragment tables, rebuild indexes, do table maintenance
- If you use innodb_flush_txn_commit=1, use a battery-backed hardware cache write controller
- more RAM is good so faster disk speed
- use 64-bit architectures
- --skip-name-resolve
- increase myisam_sort_buffer_size to optimize large inserts (this is a per-connection variable)
- look up memory tuning parameter for on-insert caching
- increase temp table size in a data warehousing environment (default is 32Mb) so it doesn't write to disk (also constrained by max_heap_table_size, default 16Mb)
- Run in SQL_MODE=STRICT to help identify warnings
- /tmp dir on battery-backed write cache
- consider battery-backed RAM for innodb logfiles
- use --safe-updates for client
- Redundant data is redundant
- Keep an eye on buffer pool and keybuffer hit rate
- InnoDB ALWAYS keeps the primary key as part of each index, so do not make the primary key very large
- Utilize different storage engines on master/slave ie, if you need fulltext indexing on a table.
- BLACKHOLE engine and replication is much faster than FEDERATED tables for things like logs.
- Know your storage engines and what performs best for your needs, know that different ones exist.
- ie, use MERGE tables ARCHIVE tables for logs
- Archive old data -- don't be a pack-rat! 2 common engines for this are ARCHIVE tables and MERGE tables
- use row-level instead of table-level locking for OLTP workloads
- try out a few schemas and storage engines in your test environment before picking one.
- Design sane query schemas. don't be afraid of table joins, often they are faster than denormalization
- Don't use boolean flags
- Use Indexes
- Don't Index Everything
- Do not duplicate indexes
- Do not use large columns in indexes if the ratio of SELECTs:INSERTs is low.
- Split out large blob elements in InnoDB
- be careful of redundant columns in an index or across indexes
- Use a clever key and ORDER BY instead of MAX
- Normalize first, and denormalize where appropriate.
- Databases are not spreadsheets, even though Access really really looks like one. Then again, Access isn't a real database
- use INET_ATON and INET_NTOA for IP addresses, not char or varchar
- make it a habit to REVERSE() email addresses, so you can easily search domains (this will help avoid wildcards at the start of LIKE queries if you want to find everyone whose e-mail is in a certain domain)
- A NULL data type can take more room to store than NOT NULL
- Avoid NULL in index attributes. Use 0 instead
- Storing flags in a database can slow down execution due to a bad cardinality. Try using bit flags
- Don't store flags in a NULL and NOT NULL manner. Update from NULL -> 1 is slower than 0 -> 1
- Choose appropriate character sets & collations -- UTF16 will store each character in 2 bytes, whether it needs it or not, latin1 is faster than UTF8.
- Use Triggers wisely
- Use delayed key wrote
- use min_rows and max_rows to specify approximate data size so space can be pre-allocated and reference points can be calculated.
- Use HASH indexing for indexing across columns with similar data prefixes
- Use myisam_pack_keys for int data
- be able to change your schema without ruining functionality of your code
- segregate tables/databases that benefit from different configuration variables
- Don't access the last key part in a where clause with =
- Abuse the system for optimiization you're using with system dependant features like RTREE's for optimized range queries
- Hire a MySQL (tm) Certified DBA
- Know that there are many consulting companies out there that can help, as well as MySQL's Professional Services.
- Read and post to MySQL Planet at http://www.planetmysql.org
- Attend the yearly MySQL Conference and Expo or other conferences with MySQL tracks (link to the conference here)
- Support your local User Group (link to forge page w/user groups here)
Authored by
Jay Pipes, Sheeri Kritzer, Bill Karwin, Ronald Bradford, Farhan "Frank Mash" Mashraqi, Taso Du Val, Ron Hu, Klinton Lee, Rick James, Alan Kasindorf, Eric Bergen, Robert Eisele, Kaj Arno, Joel Seligstein, Amy Lee, Sameer Joshi, Surat Singh BhatiWhere does Konqueror store its history, and how do I erase it?
There are several kinds of "history" stored by Konqueror.
- The location bar combobox items and completion: you can clear those with right-click, "Clear History".
- The history module in the sidebar: you can clear it with a right-click on one of the host names, and selecting "Clear History".
- The HTTP cache (known as "Temporary Internet Files" in other environments) can be cleared in the KControl module called "Cache", using the "Clear cache" button on the bottom right.
- Combobox items: ~/.kde/share/config/konq_history
- History module and combobox completion: ~/.kde/share/apps/konqueror/konq_history (binary file)
- HTTP cache: ~/.kde/share/cache/http/ (previously in ~/.kde/share/apps/kio_http/cache/)
JavaScript - Print Objects
JavaScript (sometimes abbreviated as JS) is a scripting language commonly implemented as part of a web browser in order to create enhanced user interfaces and dynamic websites.
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It uses syntax influenced by the language C. JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics. The key design principles within JavaScript are taken from the Self and Scheme programming languages. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles.
JavaScript's use in applications outside web pages — for example in PDF documents, site-specific browsers, and desktop widgets—is also significant. Newer and faster JavaScript VMs and frameworks built upon them (notably Node.js) have also increased the popularity of JavaScript for server-side web applications.
JavaScript was formalized in the ECMAScript language standard and is primarily used in the form of client-side JavaScript (as part of a web browser). This enables programmatic access to computational objects within a host environment.
// object
username: 'username',
password: 'password'
}
// print
alert(userObj.toSource());// or
for(attr in userObj){
alert(attr+ '= '+ userObj[attr]);
}
console.log(userObj);
Backtrack 5 - Ubuntu Software Center
Lets you choose from thousands of free applications available for Ubuntu.
Install
Video
With Ubuntu Software Centre, you can pick the apps you want so you won’t have anything on your computer you don’t need. And with thousands of apps to choose from, you’ll be spoilt for choice.
Each application comes with ratings and reviews to make it easier for you to decide which apps you want to install.
Install
apt-get install software-center
Video
With Ubuntu Software Centre, you can pick the apps you want so you won’t have anything on your computer you don’t need. And with thousands of apps to choose from, you’ll be spoilt for choice.
Each application comes with ratings and reviews to make it easier for you to decide which apps you want to install.
Backtrack 5 - Video Recorder | Video Capturer
- gtk-recordMyDesktop - graphical gtk frontend for recordMyDestkop
- recordmydesktop - record desktop sessions to an Ogg-Theora-Vorbis file.
- apt-get install gtk-recordMyDesktop
- apt-get install recordmydesktop
- gtk-recordMyDesktop
- recordmydesktop
recordMyDesktop is a free and open source desktop screencasting software application written for GNU/Linux. The program is separated into two parts; a command line tool that performs the tasks of capturing and encoding, and an interface that exposes the program functionality graphically. There are two front-ends written in python with pyGtk (gtk-recordMyDesktop) and pyQt4 (qt-recordMyDesktop). RecordMyDesktop also offers the ability to record audio through ALSA, OSS or the JACK audio server. RecordMyDesktop only outputs to Ogg using Theora for video and Vorbis for audio.
Subscribe to:
Posts (Atom)