This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HtmlTruncator | |
{ | |
public static string LimitOnWordBoundary(string str, int maxLength, string ellipses = "...") | |
{ | |
XmlDocument doc = new XmlDocument(); | |
XmlParserContext context = new XmlParserContext(doc.NameTable, new XmlNamespaceManager(doc.NameTable), null, XmlSpace.Preserve); | |
XmlTextReader reader = new XmlTextReader("<xml>" + str + "</xml>", XmlNodeType.Document, context); | |
bool shouldWriteEllipses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find -iname "*.csproj" -exec grep -n "MyCompany.Assembly" /dev/null {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Type[] GetGenericArgumentsForBaseType(Type givenType, Type genericType) | |
{ | |
if (genericType.IsInterface) | |
{ | |
var interfaceTypes = givenType.GetInterfaces(); | |
foreach (var it in interfaceTypes) | |
{ | |
if (it.IsGenericType && it.GetGenericTypeDefinition() == genericType) | |
return it.GetGenericArguments(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE dbname; | |
SELECT s.name | |
FROM sys.schemas s | |
WHERE s.principal_id = USER_ID('username'); | |
ALTER AUTHORIZATION ON SCHEMA::db_owner TO dbo; | |
-- from http://blog.sqlauthority.com/2011/12/26/sql-server-fix-error-15138-the-database-principal-owns-a-schema-in-the-database-and-cannot-be-dropped/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DBCC SHRINKDATABASE (UserDB, 10); | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PsExec.exe -i -u "NT AUTHORITY\NETWORK SERVICE" cmd.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# assume the index products doesn't exist | |
# otherwise uncomment the following line | |
# curl -XDELETE localhost:9200/products | |
curl -XPUT localhost:9200/products/product/1 -d'{ | |
"property1": "value1" | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# assume the index products doesn't exist | |
# otherwise uncomment the following line | |
# curl -XDELETE localhost:9200/products | |
curl -XPUT localhost:9200/products/product/1 -d'{ | |
"property1": "value1" | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
import play.api.libs.json.Format | |
import util.macroimpl.MacrosImpl | |
import language.experimental.macros | |
object JsonMacros { | |
// We did not reuse \/ from scalaz, to avoid a dependency on scalaz in the macros module | |
trait \/[A, B] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var i = 0; | |
console.log('starting app'); | |
setInterval(function() { | |
i++; | |
console.log('simulate activity'); | |
if (i > 5) { | |
doesNotExist = 0; // this will throw ReferenceError: doesNotExist is not defined | |
} |
OlderNewer