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
import glob | |
import subprocess | |
files = glob.iglob('E:/Work/web-frameworks/Python/**/*.py', recursive=True) | |
files_i_care_about = filter(lambda x: all(e not in x for e in ('venv', 'DjangoRESTPostgres')), files) | |
for filename in files_i_care_about: | |
subprocess.call(['yapf', '-vv', '-i', filename]) |
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
import glob | |
replace = 'https://github.com/osya' | |
replacement = '[email protected]:osya' | |
for filename in glob.iglob('E:/Work/**/.git/config', recursive=True): | |
with open(filename) as f: | |
s = f.read() | |
if replace in s: | |
print(filename) | |
s = s.replace(replace, replacement) |
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
/** | |
* Created by info_000 on 30-Jun-17. | |
*/ | |
"use strict"; | |
var page = require('webpage').create(), | |
fs = require('fs'); | |
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'; | |
page.onError = function (msg, trace) { | |
console.log(msg); | |
trace.forEach(function(item) { |
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
from __future__ import print_function | |
import boto3 | |
import json | |
print('Loading function') | |
def handler(event, context): | |
'''Provide an event that contains the following keys: |
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
private static MethodBase GetGenericMethod(Type type, string name, Type[] typeArgs, Type[] argTypes, BindingFlags flags) | |
{ | |
var typeArity = typeArgs.Length; | |
var methods = type.GetMethods() | |
.Where(m => m.Name == name) | |
.Where(m => m.GetGenericArguments().Length == typeArity) | |
.Select(m => m.MakeGenericMethod(typeArgs)); | |
return Type.DefaultBinder.SelectMethod(flags, methods.ToArray(), argTypes, 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
[TestMethod] | |
public async Task ExternalLoginCallbackTest() | |
{ | |
// Arrange | |
var authManager = new Mock<IAuthenticationManager>(); | |
var externalUser = new ClaimsIdentity(new[] { | |
new Claim(ClaimTypes.NameIdentifier, "10154549708179846", "http://www.w3.org/2001/XMLSchema#string", "Facebook"), | |
new Claim(ClaimTypes.Name, DummyModel.UserName, "http://www.w3.org/2001/XMLSchema#string", "Facebook") | |
}); |
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 ValidateMessagesFor | |
{ | |
public static MvcHtmlString ValidationMessagesFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) | |
{ | |
var propertyName = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).PropertyName; | |
var modelState = htmlHelper.ViewData.ModelState; | |
if (!modelState.ContainsKey(propertyName) || modelState[propertyName].Errors.Count <= 1) | |
return htmlHelper.ValidationMessageFor(expression, 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
get_distro() { | |
ARCH=$(uname -m | sed 's/x86_/amd/;s/i[3-6]86/x86/') | |
if [ $ARCH == "amd64" ]; then | |
T_ARCH="x86_64" | |
WK_ARCH="amd64" | |
else | |
T_ARCH="i386" | |
WK_ARCH="i386" | |
fi |
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 byte[] AnotherDecode64(string base64Decoded) | |
{ | |
string temp = base64Decoded.TrimEnd('='); | |
int asciiChars = temp.Length - temp.Count(c => Char.IsWhiteSpace(c)); | |
switch (asciiChars % 4) | |
{ | |
case 1: | |
//This would always produce an exception!! | |
//Regardless what (or what not) you attach to your string! | |
//Better would be some kind of throw new Exception() |
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
XmlReader xmlReader = XmlReader.Create(input); | |
XamlXmlReader reader = new XamlXmlReader(xmlReader, System.Windows.Markup.XamlReader.GetWpfSchemaContext()); | |
XamlObjectWriter writer = new XamlObjectWriter(reader.SchemaContext); | |
while (reader.Read()) | |
{ | |
switch (reader.NodeType) | |
{ | |
case XamlNodeType.StartObject: | |
if (!reader.Type.Name.Equals("Window")) |
NewerOlder