Jump to content

FreeDev

Member
  • Posts

    38
  • Joined

  • Last visited

Reputation Activity

  1. Like
    FreeDev got a reaction from chrissx in The under 100 line challenge!   
    Probably pointless, but could useful depending on the individual who is interested in IL programming and this snippet is about 140 lines of code. I created it on a whim.
     
    The purpose of this snippet is basically to emit Brainf*ck programming language into IL during runtime in C#:
     
    using System; using System.Collections.Generic; using System.Reflection.Emit; using System.Runtime.InteropServices; using System.IO; namespace BFJIT { public unsafe class BFJIT { public static void ZeroOutMemory(byte* ptr, int size) { for (int I = 0; I < size; I++) ptr[I] = 0; } public delegate IntPtr BrainFkCompile(); public BrainFkCompile Compile(string code) { var WhileBeginMarkStack = new Stack<Label>(); var WhileEndMarkStack = new Stack<Label>(); var reader = new StringReader(code); var method = new DynamicMethod($"BrainFk{Guid.NewGuid().ToString().Replace("-", "_")}", typeof(IntPtr), null); var il = method.GetILGenerator(); // Set the locals il.DeclareLocal(typeof(byte*)); il.DeclareLocal(typeof(IntPtr)); // Allocate pointer il.Emit(OpCodes.Ldc_I4, 1048576); // 1 MB Memory il.EmitCall(OpCodes.Call, typeof(Marshal).GetMethod("AllocHGlobal", new Type[] { typeof(int) }), null); il.Emit(OpCodes.Stloc_1); il.Emit(OpCodes.Ldloca_S, 1); il.EmitCall(OpCodes.Call, typeof(IntPtr).GetMethod("ToPointer"), null); il.Emit(OpCodes.Stloc_0); il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Ldc_I4, 1048576); // 1 MB Memory il.EmitCall(OpCodes.Call, typeof(BFJIT).GetMethod("ZeroOutMemory"), null); int currentCharacter = -1; do { currentCharacter = reader.Read(); switch ((char)currentCharacter) { case '>': { il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Ldc_I4_1); il.Emit(OpCodes.Add); il.Emit(OpCodes.Stloc_0); break; } case '<': { il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Ldc_I4_1); il.Emit(OpCodes.Sub); il.Emit(OpCodes.Stloc_0); break; } case '+': { il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Dup); il.Emit(OpCodes.Ldind_U1); int increment = 1; while (reader.Peek() == '+') { ++increment; reader.Read(); } il.Emit(OpCodes.Ldc_I4, increment); il.Emit(OpCodes.Add); il.Emit(OpCodes.Conv_U1); il.Emit(OpCodes.Stind_I1); break; } case '-': { il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Dup); il.Emit(OpCodes.Ldind_U1); int decrement = 1; while (reader.Peek() == '-') { ++decrement; reader.Read(); } il.Emit(OpCodes.Ldc_I4, decrement); il.Emit(OpCodes.Sub); il.Emit(OpCodes.Conv_U1); il.Emit(OpCodes.Stind_I1); break; } case '.': { il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Ldind_U1); il.EmitCall(OpCodes.Call, typeof(Console).GetMethod("Write", new[] { typeof(byte) }), null); break; } case '[': { Label begin = il.DefineLabel(); Label end = il.DefineLabel(); il.Emit(OpCodes.Br, end); il.MarkLabel(begin); WhileBeginMarkStack.Push(begin); WhileEndMarkStack.Push(end); break; } case ']': { il.MarkLabel(WhileEndMarkStack.Pop()); il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Ldind_U1); il.Emit(OpCodes.Brtrue, WhileBeginMarkStack.Pop()); break; } default: continue; } } while (currentCharacter > -1); il.Emit(OpCodes.Ldloc_1); il.Emit(OpCodes.Ret); return (BrainFkCompile)method.CreateDelegate(typeof(BrainFkCompile)); } static unsafe void Main(string[] args) { var jitter = new BFJIT(); var func = jitter.Compile("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."); Console.WriteLine("Brainfk Compiled"); var ptr = func(); Console.WriteLine(); Console.WriteLine("Program Terminated."); Marshal.FreeHGlobal(ptr); Console.ReadLine(); } } }  
  2. Agree
    FreeDev got a reaction from Ryujin2003 in Github able to withstand a massive DDoS   
    Honestly at this point, I am wondering why we haven't start cutting off China and Russian internet from the rest of the world internet, sure, it wouldn't completely block them out, but it would drastically reduce the amount of bandwidth that they are able to utilize to attack us with and quite frankly, they simply aren't going to be responsible on how they use the Internet. It have already gotten to a point that anytime you started up a new Virtual Server on Linode, Ovh, or DigitalOcean, you'll almost always see an attack coming from China or Russia trying to log into your VM Server via SSH and sometime they would try to DDOS your server as a ransom and drive up your internet usage bills.
  3. Agree
    FreeDev got a reaction from Blademaster91 in Github able to withstand a massive DDoS   
    You realize that we arrest DDOSer in Western Countries right?
     
    https://www.securityweek.com/dozens-teens-arrested-over-ddos-attacks
    http://www.zdnet.com/article/us-male-arrested-for-string-of-ddos-attacks-against-australia-north-america/
    http://www.zdnet.com/article/ddos-attacks-how-an-18-year-old-got-arrested-for-trying-to-knock-out-systems/
     
    I don't find anything like that in China/Russia.
  4. Funny
    FreeDev got a reaction from Canada EH in can a school(usa) sue for server space use   
    For fun, I've put together a Thinkmate 22 NVMe server configuration which is priced at $152,890.00 with each NVMe slot providing 6.4 tb of storage from Micron Max Series 9200 U.2 PCI-e. It basically provides 140 TB of storage with insane IO performance and essentially provides 13 GB of storage for each student in a University with 11,000 students with just one server alone, you basically can buy 4 or 5 same servers and accomplish that goal of giving each student 50 GB of shared drive space with the grand total cost of about $611,560.00 which also have 1.5 tb of RAM, 2 x Twenty-Two-Core Intel® Xeon® Processor 2.40GHz and 2x 100Gb EDR Infiniband PCI-e for each server.
     
    So when you're building servers to scale, it is generally pretty affordable.
  5. Like
    FreeDev reacted to lewis0150 in Linus just got me a pass for computer science   
    so I have been doing a computer science course for the last few months and we had an exam, as it is only a part time course we do most the research and work ourselves at home. so to get ready for my exam I watched all of the tech quicke videos (been a fan for LTT for few years so have watched most of the main channel videos) so after a week of watching every video I sat my first exam, today I found out I got a merit (B).
    just thought this is a cool thing, and wanted to share it with the community.
  6. Like
    FreeDev got a reaction from This_guy1998 in can a school(usa) sue for server space use   
    For fun, I've put together a Thinkmate 22 NVMe server configuration which is priced at $152,890.00 with each NVMe slot providing 6.4 tb of storage from Micron Max Series 9200 U.2 PCI-e. It basically provides 140 TB of storage with insane IO performance and essentially provides 13 GB of storage for each student in a University with 11,000 students with just one server alone, you basically can buy 4 or 5 same servers and accomplish that goal of giving each student 50 GB of shared drive space with the grand total cost of about $611,560.00 which also have 1.5 tb of RAM, 2 x Twenty-Two-Core Intel® Xeon® Processor 2.40GHz and 2x 100Gb EDR Infiniband PCI-e for each server.
     
    So when you're building servers to scale, it is generally pretty affordable.
  7. Agree
    FreeDev reacted to Cosmic Railgun in Windows 10 Pro vs Server 2016   
    Which version of 2012 would you recommend?
    That sounds great and all, but I really don't trust windows to detect every game I play
  8. Informative
    FreeDev reacted to GoodBytes in Windows 10 Not Opening Exe Files?   
    Nope. Even if S Mode is enabled (Start > Settings > Apps > App & features > Installing App (at the top), set it it to "Allow app from the Store only" (will not affect currently installed apps, but future ones). You'll get the following pop-up which is similar to Windows 10 S which has this option enabled just can't be turned off, when opening executables outside the store:
     

     
    In his case, it opens a web page... that is not supposed to happen. They are no webpages. The Registry was modified to re-link .exe file extensions to some website (probably a malware/virus driven one)
     
    We don't know any details yet. But essentially, it is basically Windows 10 for free or very low cost. MS probably hope, in the long term, to get its money back from Store purchases. But the reality of things, most of your "average" users won't notice. They have all they need on the Store. Office, Edge (already installed), VLC, Spotify, Pandora, Hulu, Netflix, Facebook, Messenger, Instagram, WhatsApp, Amazon Music (new), Paint.net, and more. Plus they have Windows Defender, and not all the junk pre-installed by OEMs to help drop the price of the OS, and some shitty anti-virus 30-day trial or whatever that slows down the sytem, and continues to do until it is removed, even if the trial expires. Beside Chrome or Firefox, do they miss anything? Probably not.
  9. Agree
    FreeDev reacted to Corwin111 in How long until it's mostly complete?   
    Afaik, lumberyard makes it easier to work with higher poly models and higher number of LODs and - most importantly for SC - larger environments. Cryengine was developed with classic sky boxes in mind, nobody expected it to be used for open-world stuff. Especially not on this scale! You could fit all crysis levels ever made, along with their skyboxes into the current SC Alpha's Stanton system a million times over and have room to spare.
     
    But the biggest differences are in the networking and close integration with AWS, which is also the reason they moved to AWS from google cloud.
  10. Agree
    FreeDev reacted to LogicalDrm in Is cooling air bad for health?   
    Well it isn't good for you. But due some parts of world having extremely tight regulations for anything aimed to consumers, major manufacturers have no choice but to use only non-toxic materials. So while there are stuff inside components which you shouldn't swallow and stuff like that, there isn't anything that would release toxins at rather low temps. If things would be burning, quite different thing.
     
    (You can thank EU, Canada, Japan, AU/NZ etc. USA is going wrong way atm)
  11. Like
    FreeDev got a reaction from tzebe_tzebe1 in Terminal in Community Visual Studio 2017   
    It would be included as one of the option in NodeJS installer, I've included the screenshot to highlight this.

  12. Like
    FreeDev got a reaction from tzebe_tzebe1 in Terminal in Community Visual Studio 2017   
    It basically let shell like Command Prompt or other software know where to find the binary at which includes commands like netstat, trace, dir and so forth. By adding new path to the PATH environment variable, you basically allow those software to look up on additional programs you want to run from command prompt or whatever else shell you have.
  13. Like
    FreeDev got a reaction from tzebe_tzebe1 in Terminal in Community Visual Studio 2017   
    Make sure you install or reinstall Nodejs with PATH environment variable set. NodeJS Installer
    You may have to reboot the computer when finish installing NodeJS. I wouldn't recommend running Node on Powershell interactive window in Visual Studios, it would just hang Powershell without anyway to exit Node, instead you can access Nodejs from View > Other Windows > Node.js Interactive Window assuming you have it installed as one of the Visual Studios feature and I've attached the screenshot:
     
     

  14. Informative
    FreeDev got a reaction from Joe Bennett in Windows 10 Not Opening Exe Files?   
    I'm guessing you're on Windows 10 S Mode even though the laptop seems to advertise that they are on Windows 10 Pro. I'd send it back and ask for the money back at that point for false advertising.
  15. Informative
    FreeDev got a reaction from IrshaadH in Recommended RTS games for someone new to genre?   
    Definitely a fan of Stellaris, because it's a slow paced game with a lot of elements that play around the story, diplomacy, and so forth. (It's technically a RTS with adjustable speed for fast forwarding.) On top of that, there's a Star Trek overhaul mod.
  16. Agree
    FreeDev reacted to NinJake in Should I build a PC now or wait?   
    There's so many topics of the same idea, "Do I buy now or wait". My answer will stay the same no matter what the context is.
     
    Wait if you can, save while you wait. Or buy now if you really want or need the item. (PC broke with no hope of self-repair)
×