Skip to content

Instantly share code, notes, and snippets.

@kparms
kparms / javascript_resources.md
Created November 15, 2013 16:26 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@kparms
kparms / PS-Email
Last active August 29, 2015 13:57
Email in Powershell
function sendMail([string]$arg1){
Write-Host "Sending Email"
#SMTP server name
$smtpServer = "SMTPSERVERNAME"
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
#Email structure
$msg.From = "[email protected]"
function rgb2hex(rgb) {
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {
return ("0" + parseInt(x).toString(16)).slice(-2);
}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}
//Calculates Color Contrast for text
function getContrastYIQ(hexcolor){
var r = parseInt(hexcolor.substr(0,2),16);
var g = parseInt(hexcolor.substr(2,2),16);
var b = parseInt(hexcolor.substr(4,2),16);
var yiq = ((r*299)+(g*587)+(b*114))/1000;
return (yiq >= 128) ? 'black' : 'white';
}
@kparms
kparms / drawPercentBar
Created March 11, 2014 14:16
JavaScript to draw a percentage bar in a <div>
Taken from here:
http://www.alpinemeadow.com/stitchery/weblog/HTML-morsels.html
function drawPercentBar(width, percent, color, background)
{
var barhtml = "";
var pixels = width * (percent / 100);
if (!background) { background = "none"; }
barhtml = "<div style=\"position: relative; line-height: 1em; background-color: "
@kparms
kparms / reflowTable
Created March 12, 2014 19:29
Reflow: Refresh Examples and Fix
From the example on: http://view.jquerymobile.com/1.3.1/dist/demos/examples/tables/reflow-refresh.html
You must refresh your table and use .trigger('create') to avoid the duplicated label
try to use this :
var row = "<tr><td></td></tr>"
$("#YourTable").append(row);
$("#YourTable").trigger("create");
$("#YourTable").table("refresh");
@kparms
kparms / WP-Arvixe-Error500
Created March 19, 2014 13:30
Fixing Intenal Error in Wordpress
http://blog.arvixe.com/how-to-fix-the-internal-server-error-in-wordpress/
How to Fix the Internal Server Error in WordPress
Written by TJ Marsh |Friday,17 May 2013 12 00 PM
If you have been surfing the web for more than a year, then you probably have seen the HTTP 500 Internal Server Error at least a few times. Internal Server Error is one of the common WordPress errors that can put a WordPress beginner in panic mode. Panic is the worst reaction you can have. Take a deep breath and know that others before you have had this issue as well. We have fixed errors like the internal server error, error establishing database connection, white screen of death, and others many times for our users. We can assure you that they are all fixable. It just requires a little bit of patience. In this article, we will show you how to fix the internal server error in WordPress by compiling a list of all possible solutions in one place.
Why do you get Internal Server Error in WordPress?
Internal server error is not specific to
@kparms
kparms / xsltforeachcomma
Created March 24, 2014 15:18
Comma delimited for-each loop in XSLT
<!--I use this all the time-->
<xsl:for-each select="rm:field">
<xsl:value-of select="."/>
<!-- If we're not the last item, put a comma -->
<xsl:if test="(position() &lt; last())">
<xsl:text> , </xsl:text>
</xsl:if>
</xsl:for-each>
1) Install Eclipse https://www.eclipse.org/downloads/
2) Install CDT: https://www.eclipse.org/cdt/
3) Install Cygwin: http://cygwin.com/install.html
- Make sure to go into the development section and select gcc: g++, make, and GDB.
http://www.eclipse.org/forums/index.php/t/203459/
In the Source tab of your Debug Launch Configuration you can add a Path mapping
Setup a path mapping for Cygwin in Eclipse Debug Configuration:
You have to a Path Mapping.
Compilation path: /cygdrive/c/<<path-to-eclipse-workspace>>
@kparms
kparms / jtdsquery
Created March 26, 2014 18:16
Getting JTDS to work with Stored Proc
The main challenge I was running into was SSO:
http://stackoverflow.com/questions/6356612/jtds-driver-not-working-for-sql-sever-2008r2-and-denali-native-sspi-library-not
"Try by placing the ntlmauth.dll file in the bin folder of your Java Runtime Environment (e.g. C:\Program Files\Java\jre7\bin).
I ran into the same issue using SQL Server Express 2008 R2 and this MSDN SQL Server Forum Article recommended this resolution, which worked for me."
I downloaded JTDS-dist and copied the ntlmauth.dll into the jre/bin folder.
The second challenge was the stored procedure did not return a result set, only a message, we got around that with the following: