Skip to content

Instantly share code, notes, and snippets.

View JosiahSiegel's full-sized avatar
🌌

Josiah Siegel JosiahSiegel

🌌
View GitHub Profile
@JosiahSiegel
JosiahSiegel / MyPage.aspx
Last active June 2, 2017 17:18
#ASP .NET TextBox: Set default & per page range validation
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MyPage.aspx.cs" Inherits="MyProject.Pages.MyPage" %>
<%@ Register TagPrefix="uc" TagName="StartDateRequired" Src="~/WebUserControl/StartDateRequired.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<uc:StartDateRequired ID="TextBoxStartDate" runat="server" />
</asp:Content>
@JosiahSiegel
JosiahSiegel / DisplayRoles.aspx.cs
Last active June 2, 2017 17:18
#ASP .NET Create hierarchically sorted roles page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using MyProject.DAO.TableAdapters;
namespace MyProject.Pages
@JosiahSiegel
JosiahSiegel / netezza_dedupe.sql
Created November 26, 2014 17:18
#Netezza Deduplicate all data in table
delete from TEST_DATA c where exists
(select rowid from TEST_DATA a
left outer join(
select min (rowid) as min_row, MSG_ID, MSG_ID2
FROM TEST_DATA
GROUP BY MSG_ID, MSG_ID2
) x on a.rowid = x.min_row
where x.min_row is null and a.rowid = c.rowid);
@JosiahSiegel
JosiahSiegel / csv_upload.aspx.cs
Last active June 2, 2017 17:18
#ASP .NET csv upload fix
protected void Page_Load(object sender, EventArgs e)
{
Page.Form.Attributes.Add("enctype", "multipart/form-data");
}
@JosiahSiegel
JosiahSiegel / jasper_cert.sh
Last active June 2, 2017 17:18
#JasperServer Add SLL certificate into Java keystore
keytool -keystore /path_to_studio_jre/lib/security/cacerts -importcert -alias jasperca -file /path_to_cer/public.cer
@JosiahSiegel
JosiahSiegel / auth_token.rb
Last active June 2, 2017 17:17
#Rails Generate unique authorization token for user
begin
auth_token = SecureRandom.uuid.gsub(/\-/,'')
end while User.exists?(auth_token: auth_token)
@JosiahSiegel
JosiahSiegel / soap.rb
Last active June 2, 2017 17:17
#Rails Use Savon to make SOAP request
def self.soap_method(input)
c = Savon.client(wsdl: 'http://0.0.0.0/path_of_wsdl.wsdl', ssl_verify_mode: :none)
r = c.call(:soap_method, xml:
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:com='http://www.company.com'>
<soapenv:Header/>
<soapenv:Body>
<com:SoapMethod>
<com:input>
<!--Soap Body-->
</com:input>
@JosiahSiegel
JosiahSiegel / soap_xml.rb
Last active June 2, 2017 17:17
#Rails Use Savon to make request and retrieve XML result
private
def self.get_response
c = Savon.client(wsdl: 'local_wsdl.wsdl', ssl_verify_mode: :none)
r = c.call(:login, message: { "String_1" => "xxxx", "String_2" => Rails.application.secrets.SECRET }, response_parser: :rexml)
result_xml = Nokogiri::XML(r.body[:response][:result])
response = Hash.from_xml(result_xml.to_s)
response["Response"]
end
@JosiahSiegel
JosiahSiegel / rest_api.rb
Last active June 2, 2017 17:17
#Rails Call a REST API
class RestApi
include HTTParty
base_uri 'http://url/api/v1'
def self.get_info(id)
response = get("/info/#{id}")
response["count"] > 0 ? response["results"]["info"] : "Not Found"
end
end
@JosiahSiegel
JosiahSiegel / stored_procedure.rb
Last active June 2, 2017 17:17
#Rails Call stored procedure and retrieve return value
class StoredProcedure
def self.return_value name, *args
ActiveRecord::Base.connection_pool.with_connection do |connection|
args = args.map{|e| connection.quote e}
output = connection.select_all("Declare @status int;" +
"EXEC @status = #{name} #{args.join(',')};" +
"select @status as status;")
return_value = Hash[*output]
return_value["status"]
end