Skip to content

Instantly share code, notes, and snippets.

Anthony DeFreitas biganth

Block or report user

Report or block biganth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@biganth
biganth / StreamToExcel.cs
Created Mar 23, 2016
Export a stream of data to CSV
View StreamToExcel.cs
FileStream fileStream = new FileStream("C:\\Temp\\EncompassExtract.csv", FileMode.Create);
var streamWriter = new StreamWriter(fileStream);
streamWriter.AutoFlush = true;
StringBuilder line = new StringBuilder();
line.AppendFormat("User" + "," + "UserId" + "," + "Account Enabled");
line.Append(Environment.NewLine);
foreach (User user in users)
{
line.AppendFormat(user.FullName + "," + user.Id + "," + user.Enabled);
line.Append(Environment.NewLine);
@biganth
biganth / slugIt.js
Last active Apr 1, 2016
Create urls based on blog post title
View slugIt.js
//Turns "My first blog post" into my-first-blog-post
function slugIt() {
let title = document.getElementById("title");
let slug = document.getElementById("slug");
slug.value = title.value.replace(/ /g, "-").toLowerCase();
}
@biganth
biganth / web-api-external-login.js
Last active Mar 23, 2016
Web API2 external login
View web-api-external-login.js
function Login() {
jQuery.support.cors = true;
$.ajax({
type: 'GET',
url: 'api/Account/ExternalLogins?returnUrl=%2F&generateState=true',
dataType: 'JSON',
success: function (data) {
var url = (data[0].Url);
window.open(url, '_self', false);
}
@biganth
biganth / Angular-Web-API2.js
Last active Apr 1, 2016
Angular hitting Web API 2
View Angular-Web-API2.js
var app = angular.module('CarFinderApp', []);
app.controller('DisplayController', ['$scope', '$http', function ($scope, $http) {
$scope.selected = {
year: '',
make: '',
model: '',
trim: ''
};
}
@biganth
biganth / rails-search.html
Last active Mar 23, 2016
Rails search with Twitter Typeahead
View rails-search.html
<form id="search_form" action="/listings/search" method="get">
<%= hidden_field_tag :search_item_id %>
<%= hidden_field_tag :search_item_type %>
<fieldset>
<span class="search">
<% q = params[:term].to_s.empty? ? "Instant search result as you type" : params[:term] %>
<script>var start_search = true</script>
<input type="text" class="input" id="search_field" name="q" value="<%=q%>" onclick="if(this.value=='Instant search results as you type'){this.value=''};start_search=true;$('search_results').hide()" autocomplete="off" />
&nbsp;<%= indicator("search_ind") %>
</span>
You can’t perform that action at this time.