Skip to content

Instantly share code, notes, and snippets.

namespace ServicesTool2.ViewModel
{
using System;
using System.DirectoryServices.AccountManagement;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
:: Guides and examples can be found at:
:: http://forums.guru3d.com/showthread.php?t=356046
:: Script needs to be set as a system startup batch file with the highest priority and system privilages to work correctly.
:: Init the ramdrive (6GB) in physical memory and format it as ntfs
imdisk -a -s 6G -m R: -p "/fs:ntfs /q /y" -o awe
:: add a page file starting with 96MB and expands to 1536M
swapadd R:\pagefile.sys 96M 1536M
# coding=utf-8
from os import path
from time import sleep
from urllib.request import urlopen
from datetime import datetime
from smtplib import SMTP
from bs4 import BeautifulSoup
DEBUG_TAG = '[{name}]'.format(name=path.basename(__file__))
IP_LOOKUP_URL = 'http://whatismyip.org'
case class City(id: Long, name: String)
case class State(id: Long, abbr: String, name: String)
def citiesInPostal(postal: Long): DBIO[Seq[(City, State, Long)]] = {
sql"""SELECT c.id, c.name, s.id, s.abbr, s.name, csp.id
FROM location_identifier AS li,
cities AS c,
states AS s,
city_state_postal AS csp
WHERE csp.postal_code = ${postal}
import slick.backend.DatabaseConfig
import slick.dbio.{NoStream, Effect}
import slick.driver.JdbcProfile
import slick.jdbc.JdbcBackend
import slick.profile.{SqlStreamingAction, SqlAction}
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.io.Source
package Extensions
import dispatch._
import slick.dbio.{NoStream, Effect}
import slick.jdbc.JdbcBackend
import slick.profile.{SqlAction, SqlStreamingAction}
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@yareally
yareally / tests.cs
Last active June 10, 2016 23:00
Using AutoFixture + Moq + Microsoft Fakes to test a static method that calls to some Windows APIs
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ServiceProcess;
using System.Linq;
using Microsoft.QualityTools.Testing.Fakes;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoMoq;
using ServicesTool2.Models;
namespace ServicesToolTests {
var haystack = "AABBCC";
var matches = rules.Where(kv => haystack.Contains(kv.Key)).ToDictionary(kv => kv.Key, kv => kv.Value);
var needle = matches.Any() ? matches.ElementAt(new Random().Next(matches.Count)).Key : "";
haystack.Replace(needle, rules[needle]);
@yareally
yareally / client_server.pl
Created August 17, 2016 06:13
old school lab
#!/usr/local/bin/perl -w
use strict;
use IO::Socket::INET;
use Sys::Hostname;
use Data::Dumper;
my ($remote_host, $remote_port);
$remote_port = $ARGV[0];
my $hostname = `hostname`;
class MainActivity extends BaseActivity {
private lazy val signalStr : PhoneStateListener = onSignalChanged((signalStrength) ⇒ {
if (signalStrength != null) {
lazy val signalWrapper = new SignalArrayWrapper(signalStrength.toString)
filteredSignals = signalWrapper.filterSignals(signalStrength.toString)
displayDebugInfo(signalWrapper)
displaySignalInfo(filteredSignals)
}
})