Skip to content

Instantly share code, notes, and snippets.

@bungard
bungard / gist:de321995a418bbd0f479
Last active August 29, 2015 14:04
C# to fill PDF form from a Given DataTable
/*
This is utilizing iTextSharp for the PdfReader, PdfStamper and AcroFields classes.
*/
DataTable dt = new DataTable();/* fill the DT however you please */
String pdfTemplate = "PATH_TO_PDF_FORM";
System.IO.MemoryStream m = new System.IO.MemoryStream();
PdfReader pdfReader = new PdfReader(pdfTemplate);
PdfStamper pdfStamper = new PdfStamper(pdfReader, m);
SELECT model
FROM
(SELECT model, price FROM PC)
UNION
(SELECT model, price FROM Laptop)
UNION
(SELECT model, price FROM PC) model_price
WHERE
price >= ALL (SELECT price FROM model_price);
@bungard
bungard / ldap_bind.rb
Last active August 29, 2015 14:11
LDAP Bind/Authenticate
require 'ldap'
LDAP_S ={
:use_ssl => true,
:ldap_host => "domain.com",
:domain => "domain.com",
:start_tls => false,
:ldap_version => 3
}
function parseExcel{
param(
[string] $strFileName = $(throw "Please specify an excel file to parse."),
[string] $strSheetName = 'Sheet1$',
[string] $callListId = $(throw "Please specify a callListId.")
)
$strProvider = "Provider=Microsoft.Jet.OLEDB.4.0"
$strDataSource = "Data Source = $strFileName"
$strExtend = "Extended Properties=Excel 8.0"
$strQuery = "Select * from [$strSheetName]"
require 'rails/commands/server'
require 'socket'
module Rails
class Server
alias :default_options_alias :default_options
def default_options
ip_addr_list = Socket.ip_address_list
#puts ip_addr_list.inspect
if ip_addr_list.count >= 2
cp $1 $1.oldKey
AUTH_KEY=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/ | grep "'AUTH_KEY'" | sed 's/[^-A-Za-z0-9_]/\\&/g')
SECURE_AUTH_KEY=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/ | grep "'SECURE_AUTH_KEY'" | sed 's/[^-A-Za-z0-9_]/\\&/g')
LOGGED_IN_KEY=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/ | grep "'LOGGED_IN_KEY'" | sed 's/[^-A-Za-z0-9_]/\\&/g')
NONCE_KEY=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/ | grep "'NONCE_KEY'" | sed 's/[^-A-Za-z0-9_]/\\&/g')
AUTH_SALT=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/ | grep "'AUTH_SALT'" | sed 's/[^-A-Za-z0-9_]/\\&/g')
SECURE_AUTH_SALT=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/ | grep "'SECURE_AUTH_SALT'" | sed 's/[^-A-Za-z0-9_]/\\&/g')
@bungard
bungard / WP-clean.sh
Created February 19, 2015 00:12
Shell script to try and detect and clean common WP infections
grep -lr --include \*.php --exclude \*id3v2.php "%x[0-9]" . | tee infected-files.txt
while read -r filename ; do
cp -v "$filename" "$filename.dirty"
sed -i "s/<?php \$\w\+ = '.*%x[0-9].*?>//g" "$filename"
done < infected-files.txt
$query_select = "select lead.id ";
$query_from = "";
$query_where = " where lead.form_id = $form_id";
$query_order = "";
if(!empty($orderby_field))
$query_order = " ORDER BY " . preg_replace("([^0-9A-Za-z_])","",$orderby_field[0]["label"]) . ".value desc ";
$query_from .= " from wp_rg_lead lead
INNER JOIN wp_rg_lead_detail approval on lead.form_id = approval.form_id and lead.id = approval.lead_id
//As pulled from: http://support.microsoft.com/kb/306158
static private bool impersonateValidUser(String userName, String domain, String password)
{
WindowsIdentity tempWindowsIdentity;
IntPtr token = IntPtr.Zero;
IntPtr tokenDuplicate = IntPtr.Zero;
if (RevertToSelf())
{
if (LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE,
Application Error:
Application: Plex.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
Stack:
at System.Environment.FailFast(System.String, System.Exception)
at Plex.App+<FlushBugSenseAndFailFastAsync>d__47.MoveNext()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)