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 bool HasInternet() | |
{ | |
var connectionProfile = NetworkInformation.GetInternetConnectionProfile(); | |
return (connectionProfile != null && | |
connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess); | |
} |
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
$shell = New-Object -ComObject "Shell.Application" | |
$iisx = 'c:\Program Files (x86)\IIS Express\iisexpress.exe' | |
$path = (Resolve-path .) # eller hårdkoda path eller ta in som parameter | |
"" > "$path/input.txt" | |
$params = "/port:8080","/path:$path" | |
Write-Host $params | |
Start-Process -FilePath $iisx -ArgumentList $params -NoNewWindow -RedirectStandardOutput output.txt -RedirectStandardInput input.txt | |
$shell.minimizeall() |
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 requests | |
url = 'http://somedomain' | |
basic = ('basic-un','basic-pw') | |
payload = {'someVar' : 'someVal'} | |
customHeaders = {'content-type': 'application/json'} | |
result = requests.post(url,auth=basic,data=payload,headers=customHeaders) |
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 tornado.ioloop | |
import tornado.web | |
import tornado.httpclient | |
class MainHandler(tornado.web.RequestHandler): | |
def post(self): | |
data = self.request.body | |
print("Print from server: {0}".format(data)) | |
self.write(data) |
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
function hexToString(hexValue) { | |
var hex = hexValue.toString(); | |
var str = ''; | |
for (var i = 0; i < hex.length; i += 2) | |
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); | |
return str; | |
} | |
var dateVal = new Date(hexToString(aHexValueGoesHere)); |
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 PWM | |
#pwm = PWM(0x40) | |
#pwm.setPWMFreq(60) #60hz | |
servoMin = 1 | |
servoMax = 800 | |
def setPWMDegrees(channel,degrees): | |
clampedValue = max(1,min(degrees,360)) | |
fraction = clampedValue / 360 |
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
#---------STUFF THAT YOU SHOULD EDIT-- | |
$username = "yourusername" | |
$apitoken = "yourapitoken" #Get an api-token at https://www.name.com/reseller usually doesn't take long | |
$domain = "yourdomain" #e.g example.com | |
$hostname = "yourhostname" #The hostname that you want to update, for mail.example.com the hostname should be "mail" | |
# | |
#------------------------------------ | |
$headers = @{"Api-Username"= $username;"Api-Token" = $apitoken} | |
$listUrl = "https://api.name.com/api/dns/list/$domain" |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
//Create a list of 20 anon objects wiht Name and Age |
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
c:\windows\system32\powercfg.exe -change -monitor-timeout-ac 0 | |
c:\windows\system32\powercfg.exe -change -monitor-timeout-dc 0 | |
c:\windows\system32\powercfg.exe -change -disk-timeout-ac 0 | |
c:\windows\system32\powercfg.exe -change -disk-timeout-dc 0 | |
c:\windows\system32\powercfg.exe -change -standby-timeout-ac 0 | |
c:\windows\system32\powercfg.exe -change -standby-timeout-dc 0 | |
c:\windows\system32\powercfg.exe -change -hibernate-timeout-ac 0 | |
c:\windows\system32\powercfg.exe -change -hibernate-timeout-dc 0 |
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
type Res<'TSuccess,'TFailure> = | |
| Success of 'TSuccess | |
| Failure of 'TFailure | |
let succeed x = | |
Success x | |
let fail x = | |
Failure x | |
let either successFunc failureFunc x2Rop = | |
match x2Rop with | |
| Success s -> successFunc s |