Skip to content

Instantly share code, notes, and snippets.

View webgio's full-sized avatar

Giorgio Bozio webgio

  • Viva Software
  • Italy
View GitHub Profile
@webgio
webgio / shrink
Last active August 29, 2015 14:00
T-SQL query to get tables size
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo __pycache__ *.rej *~ #*# .#* .*.swp .DS_Store Packages packages bin obj *.suo *.user
@webgio
webgio / gist:4344033
Created December 20, 2012 09:10
Lexicographical next string, to use for autocomplete searches with startkey and endkey parameters. (CouchDb, Azure Storage tables ... )
public static string LexicographicallyNextString(string starting)
{
starting = starting.ToLowerInvariant();
char last = starting[starting.Length - 1];
int position = last;
int next = ++position;
char nextChar = (char)next;
string endStarting = starting.Substring(0, starting.Length - 1) + nextChar.ToString();
return endStarting;
}
/* =============================================================
* bootstrap-typeahead-backbone.js v2.0.0
* http://twitter.github.com/bootstrap/javascript.html#typeahead
* https://github.com/twitter/bootstrap/blob/master/js/bootstrap-typeahead.js
* Modified by Marius Andreiana to work with Backbone Collection, Model, View
* - custom results formatting
* - custom behavior on selected item (Model with complex information)
* =============================================================
* Copyright 2012 Twitter, Inc.
*
_.extend Backbone.Validation.callbacks,
valid: (view, attr, selector) ->
control = view.$('[' + selector + '=' + attr + ']')
group = control.parents(".control-group")
group.removeClass("error")
if control.data("error-style") == "tooltip"
# CAUTION: calling tooltip("hide") on an uninitialized tooltip
# causes bootstraps tooltips to crash somehow...
control.tooltip "hide" if control.data("tooltip")
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@webgio
webgio / JasmineSpec.coffee
Last active December 11, 2015 21:48
Sample Jasmine test for Marionette.js module
describe 'App.HeaderModule', ->
beforeEach ->
@headerModule = window.App.HeaderModule
it 'should exist', ->
expect(@headerModule).not.toBeUndefined()
describe 'starting', ->
@webgio
webgio / index.html
Last active December 17, 2015 22:59
coffee pastry widget
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/lib/jquery.js"></script>
<script type="text/javascript" src="js/lib/underscore-min.js"></script>
<script type="text/javascript" src="js/lib/backbone.js"></script>
<script type="text/javascript" src="js/lib/backbone.marionette.js"></script>
<script type="text/javascript" src="js/lib/handlebars.js"></script>
<script type="text/javascript" src="js/widget.js"></script>
<title>testing widget</title>
@webgio
webgio / RotativaHQ_header_footer.cs
Last active September 3, 2016 13:45
RotativaHQ header and footer
public static bool PdfContains(byte[] pdfcontent, string text)
{
using (var pdfReader = new PdfReader(pdfcontent))
{
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
var strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(
pdfReader, page, strategy);