## Tech Here are just a few notes I quickly need access from time to time. ### AWS - S3 ``` { "Version": "2012-10-17", "Statement": [ { "Sid": "Statement", "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetObject", "s3:DeleteObject", "s3:PutObject" ], "Resource": [ "arn:aws:s3:::/*", "arn:aws:s3:::" ] } ] } ``` ### AWS - Static websites with CloudFront * [Setup the website](https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-serve-static-website/) * [Auto-resolve /folder/ -> /folder/index.html](https://aws.amazon.com/blogs/networking-and-content-delivery/implementing-default-directory-indexes-in-amazon-s3-backed-amazon-cloudfront-origins-using-cloudfront-functions/) ### Bash * [Print arguments of a bash shell](http://www.linuxquestions.org/questions/programming-9/processing-command-args-in-bash-367563/) * [Bash Pitfalls](http://mywiki.wooledge.org/BashPitfalls) ### DTrace #### Tutorials * [http://www.oracle.com/technetwork/server-storage/solaris/dtrace-tutorial-142317.html](http://www.oracle.com/technetwork/server-storage/solaris/dtrace-tutorial-142317.html) * [https://www.bignerdranch.com/blog/hooked-on-dtrace-part-1/](https://www.bignerdranch.com/blog/hooked-on-dtrace-part-1/) * [https://www.bignerdranch.com/blog/hooked-on-dtrace-part-2/](https://www.bignerdranch.com/blog/hooked-on-dtrace-part-2/) * [https://www.bignerdranch.com/blog/hooked-on-dtrace-part-3/](https://www.bignerdranch.com/blog/hooked-on-dtrace-part-3/) * [https://www.bignerdranch.com/blog/hooked-on-dtrace-part-4/](https://www.bignerdranch.com/blog/hooked-on-dtrace-part-3/) * [http://www.brendangregg.com/dtrace.html](http://www.brendangregg.com/dtrace.html) ### MySQL #### Getting database/table sizes ``` SELECT table_schema "TABLENAME", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ``` #### Getting table size ordered by size (desc) ``` SELECT table_schema as `Database`, table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES ORDER BY (data_length + index_length) DESC; ``` ### OpenSSL #### Lazy man's self-signed certificate openssl req -subj "/CN=domain.com/O=My Company Name LTD./C=US" -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt -sha256 #### Check if everything matches up $ openssl rsa -in wildcard.domain.key -noout -modulus | openssl md5 $ openssl x509 -in wildcard.domain.com.crt -noout -modulus | openssl md5 $ openssl req -in wildcard.domain.com.csr -noout -modulus | openssl md5 ### Saltstack ![Description](https://pbs.twimg.com/media/CHxoz_UUkAA3_Gt.png) #### Installation ##### Debian sudo apt-get -y install python-software-properties sudo add-apt-repository -y ppa:saltstack/salt sudo apt-get update sudo apt-get -y install salt-master ( or salt-minion) #### Fun Stuff ##### All grains salt '*' grains.items ##### All Stuff salt '*' status.all_status #### Updating a package on every machine salt \* pkg.install lxc-docker refresh=true #### Updating saltstack on all the minions salt \* file.replace /etc/salt/minion pattern='master_type: str' repl='master_type: standard' salt \* cmd.run 'apt-get update' salt \* cmd.run 'apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y salt-minion' #### Massive errors on highstate from minions after an upgrade? /etc/init.d/salt-minion stop cd /var/cache/salt/minion rm -rf * /etc/init.d/salt-minion start ## Gaming ### ArmA #### Introduction I have been playing Operation: Flashpoint and its Resistance expansion back in the day, started scripting things for it and made a ton of scenarios and a larger bunch of scripts. I've played the SP campaign of ArmA. I started playing ArmA 2 and its expansions mid-2010, after which I got the taste of scripting and making scenarios again. Safe to say I've spent many nights scripting SQF in the RV engine. Over time I've collected a bunch of notes and scripts I've used to create my scenarios. It would be selfish to keep them for myself, so here are they. I've tried to sort them on version (ArmA 2 and ArmA 3) and mod (just ACE2). #### General SQF The following examples should work in both ArmA 2and ArmA 3. #### Everything about groups ##### Create a new group _grp = group this ##### Moving all units of a group into a vehicle {_x moveincargo taxi} foreach units group this ##### Check if a group is inside a vehicle ({_x in taxi} count units grp1) == (count units grp1) ##### Check if a group is not inside a vehicle {_x in taxi} count (units grp1) == 0 ##### Check to see if all playable west units are in a trigger area {alive _x && side _x == WEST && vehicle _x in thislist} count allunits == {alive _x && side _x == WEST} count allunits #### Start a script that is part of a mod (requires CBA) Put in `config.cpp`: ``` class CfgPatches { class gfs { units[] = {}; weapons[] = {}; requiredVersion = 1.00; requiredAddons[] = {"CBA_MAIN"}; author[] = {"Sacha Ligthert"}; versionDesc = "This latest version"; version = "0.29"; }; }; class Extended_PreInit_EventHandlers { class gfs { init = "[] execVM 'folder\init.sqf';"; }; ``` #### Mute in-game radio commands 0 fadeRadio 0; //mute in-game radio commands #### Removing the Respawn Button ``` private["_display","_btnRespawn"]; disableSerialization; waitUntil { _display = findDisplay 49; !isNull _display; }; _btnRespawn = _display displayCtrl 1010; _btnRespawn ctrlEnable false; ``` #### Detect a JIP ``` if (!(isNull player)) then //non-JIP player { }; if (!isServer && isNull player) then //JIP player { }; ``` #### Count the building positions ``` x = 0; while { format ["%1", house buildingPos x] != "[0,0,0]" } do {x = x + 1}; hint format ["%2: 0 - %1", x-1, "Available positions"]; ``` #### Locations and Buildings ##### Find all in the cities ``` SL_fnc_urbanAreas = { private ["_locations","_cityTypes","_randomLoc","_x","_i","_cities"]; _i = 0; _cities = []; _locations = configfile >> "CfgWorlds" >> worldName >> "Names"; _cityTypes = ["NameVillage","NameCity","NameCityCapital"]; for "_x" from 0 to (count _locations - 1) do { _randomLoc = _locations select _x; // get city info _cityName = getText(_randomLoc >> "name"); _cityPos = getArray(_randomLoc >> "position"); _cityRadA = getNumber(_randomLoc >> "radiusA"); _cityRadB = getNumber(_randomLoc >> "radiusB"); _cityType = getText(_randomLoc >> "type"); _cityAngle = getNumber(_randomLoc >> "angle"); if (_cityType in _cityTypes) then { _cities set [_i,[_cityName, _cityPos, _cityRadA, _cityRadB, _cityType, _cityAngle]]; _i = _i + 1; }; }; _cities; }; ``` #### Find all the buildings in a give area... ``` SL_fnc_findBuildings = { private ["_center","_radius","_buildings"]; _center = _this select 0; _radius = _this select 1; _buildings = nearestObjects [_center, ["house"], _radius]; _buildings; }; ``` #### ACRE ##### Disable Signal loss (Long range radios now cover the entire island.) [0] call acre_api_fnc_setLossModelScale; ##### Retransmit script Source [http://www.tacticalgamer.com/script-bin/176053-script-acre-retransmit-script.html](http://www.tacticalgamer.com/script-bin/176053-script-acre-retransmit-script.html) //Retransmit on Position + Altitude private ["_obj","_pos"]; _obj = _this; _pos = getPosATL _obj; [[_pos select 0, _pos select 1, (_pos select 2) + 4500], 51.850, 54.500, 20000] call acre_api_fnc_createRxmtStatic; ##### Segment the radio frequencies per faction if (!isDedicated) then { if (isNull player) then { waitUntil {!isNull player}; }; #define FREQ_BASE 30 _freqs = []; if (side player == WEST) then { for "_i" from 0 to 99 do { _freq = FREQ_BASE + (_i * 3) + 0.500; _freqs = _freqs + [_freq]; }; } else { for "_i" from 0 to 99 do { _freq = FREQ_BASE + (_i * 3) + 1.250; _freqs = _freqs + [_freq]; }; }; ["ACRE_PRC148", _freqs] call acre_api_fnc_setDefaultChannels; ["ACRE_PRC117F", _freqs] call acre_api_fnc_setDefaultChannels; ["ACE_P159_RD99", _freqs] call acre_api_fnc_setDefaultChannels; #define FREQ_BASE 2400 _freqs = []; if (side player == WEST) then { for "_i" from 0 to 99 do { _freq = FREQ_BASE + _i + 0.200; //_freqs = _freqs + _freq, 50; _freqs = _freqs + [_freq]; }; } else { for "_i" from 0 to 99 do { _freq = FREQ_BASE + _i + 0.600; //_freqs = _freqs + _freq, 50; _freqs = _freqs + [_freq]; }; };; ["ACRE_PRC343", _freqs] call acre_api_fnc_setDefaultChannels; }; #### ArmA 2 ##### Disable Greetings menu player setVariable ["BIS_noCoreConversations", true]; //disable greeting menu ##### Place and LHD virtually anywere * Module: Functions * GameLogic LHD1 * init.sqf: * `waituntil {!isnil "bis_fnc_init"}; LHD1 call BIS_EW_fnc_createLHD;` * GameLogic * `this setDir 90; this setPos [ getPos this select 0, getPos this select 1, (getPos this select 2) -15.6];` ##### Players start with a lowered weapon player switchMove "amovpercmstpslowwrfldnon_player_idlesteady03"; //lower players weapon ##### Spawn a camp by using DYNO if(isServer || isDedicated)then { _newComp = [(getPos this), (getDir this), "Camp1_TKM_EP1"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf ")); }; #### ACE2 ##### Start with earplugs in //earplugs #define __check configFile >> "CfgIdentities" >> "Identity" >> "name" _earplugs = { if ( ((getText(__check) == "") || (getText(__check) != (name player))) && isMultiplayer ) then { // indentity incorrect // don't wait } else { // wait for init waitUntil { sleep 0.5; _earplugs = player getVariable "ace_sys_goggles_earplugs"; !isNil "_earplugs" }; }; player setVariable ["ace_sys_goggles_earplugs", true, false]; player setVariable ["ace_ear_protection", true, false]; }; [] spawn _earplugs; #### ArmA 3 ##### Custom Radio Channels * [https://community.bistudio.com/wiki/customRadio](https://community.bistudio.com/wiki/customRadio) - Sends a msg over a custom channel * [https://community.bistudio.com/wiki/fadeRadio](https://community.bistudio.com/wiki/fadeRadio) - Fades radio * [https://community.bistudio.com/wiki/radioChannelAdd](https://community.bistudio.com/wiki/radioChannelAdd) * [https://community.bistudio.com/wiki/radioChannelCreate](https://community.bistudio.com/wiki/radioChannelCreate) * [https://community.bistudio.com/wiki/radioChannelRemove](https://community.bistudio.com/wiki/radioChannelRemove) * [https://community.bistudio.com/wiki/radioChannelSetCallSign](https://community.bistudio.com/wiki/radioChannelSetCallSign) * [https://community.bistudio.com/wiki/radioChannelSetLabel](https://community.bistudio.com/wiki/radioChannelSetLabel) * [https://community.bistudio.com/wiki/radioVolume](https://community.bistudio.com/wiki/radioVolume) ##### Give all to zeus _curator addCuratorEditableObjects [vehicles,true]; _curator addCuratorEditableObjects [(allMissionObjects "Man"),false]; _curator addCuratorEditableObjects [(allMissionObjects "Air"),true]; _curator addCuratorEditableObjects [(allMissionObjects "Ammo"),false]; #### ACE3 ##### Removing NVG grain ppEffectDestroy ace_nightvision_ppEffectFilmGrain; ##### Detecting if ACE3 is running * `"ace_main" in activatedAddons` * `isClass (configFile >> "cfgPatches" >> "ace_main")` * `missionNamespace getVariable ["ace_common", false]` ##### Have a unit never go prone or run away this addEventHandler ["Animchanged",{(_this select 0) setunitpos "up"}]; this allowFleeing 0; this forceSpeed 0; ##### Adding stuff to cargo ["ACE_ConcertinaWireCoil ",vehicleVarName] call ace_cargo_fnc_addCargoItem #### ALiVE ##### Profile all non-profiled units [false, [_grp1,_grp2,_grp3,_grp4], nil ] call ALIVE_fnc_createProfilesFromUnitsRuntime; ##### Prevent a group from being profiled _grp1 setVariable ["ALIVE_profileIgnore", true]; ##### Marking Active Units [] call ALIVE_fnc_markUnits ##### Enabling profile debug ALiVE_SYS_PROFILE setVariable ["debug","false", true]; ##### Enabling profile debug [] call ALIVE_fnc_profileSystemDebug; ##### Toggle IED and OPCOM installations [] call ALIVE_fnc_OPCOMToggleInstallations; ##### Storing stuff in databases * `ALiVE_fnc_getHash` * `ALiVE_fnc_setHash` ``` ligthert [6:56 PM] @highhead: Do you happen to know something about the _getHash and _setHash functions? highhead [6:57 PM] its a wrapper for the CBA fncs highhead [6:57 PM] what do you need highhead [6:58 PM] actually they set and get data to arrays that look like ["CBA_HASH",_key,_value,_defaultValue] highhead [6:58 PM] HashGet allows you to return custom defaultvalues ligthert [7:01 PM] The reason I am asking is because I found out that despite persistence's best efforts some vehicles and objects (and objectives) don't stay dead after loading the scenario again. I was thinking of putting all these objectives and objects in an array and have the stored in the database. Basically abusing _setHash and _getHash as a glorified database abstraction layer to counteract this problem. :simple_smile: highhead [7:01 PM] so you can basically store ANY data easily by.... _myDataHandler = [] call ALiVE_fnc_HashCreate; [_myDataHandler,"age",36] call ALiVE_fnc_HashSet; [_myDataHandler,"size",185] call ALiVE_fnc_HashSet; [_myDataHandler,"eyes","blue"] call ALiVE_fnc_HashSet; [_myDataHandler,"gay",false] call ALiVE_fnc_HashSet; [_myDataHandler,"body",objNull] call ALiVE_fnc_HashSet; you can then get the data with: _age = [_myDataHandler,"age",100] call ALiVE_fnc_HashGet; etc.... ligthert [7:02 PM] but but but, in the last example you put down ​_100_​, won't this fudge the value you get from hashGet up? ligthert [7:02 PM] Or is this de default value? highhead [7:03 PM] if the the age data within _myDataHandler would be not existing it would return 100 highhead [7:03 PM] default value ligthert [7:05 PM] I see. :simple_smile: ligthert [7:05 PM] Are these hashes in a ​_namespace_​ of the scenario or can I steal other people's hashes? :simple_smile: Pause OPCOM when the last player disconnected In the initServer.sqf: ["someId", "onPlayerConnected", { if (({isPlayer _x} count playableUnits) > 0 || OPCOM_TOGGLE) then { ["ALIVE_MIL_OPCOM"] call ALiVE_fnc_unPauseModule; OPCOM_TOGGLE = false; };}] call BIS_fnc_addStackedEventHandler; ["someId", "onPlayerDisconnected", { if ( ({isPlayer _x} count playableUnits) == 0 ) then { ["ALIVE_MIL_OPCOM"] call ALiVE_fnc_pauseModule; OPCOM_TOGGLE = true; };}] call BIS_fnc_addStackedEventHandler; Putting crates into objects [ALiVE_SYS_LOGISTICS,"fillContainer",[_vehicle,_payload]] call ALiVE_fnc_Logistics; _payload is an array with class-names or objects ``` ##### Opening stuff from addAction ``` this addAction ["Operations", {["OPEN_OPS",[]] call ALIVE_fnc_SCOMTabletOnAction}]; this addAction ["Intel", {["OPEN_INTEL",[]] call ALIVE_fnc_SCOMTabletOnAction}]; this addAction ["Logistics", {["OPEN",[]] call ALIVE_fnc_PRTabletOnAction}]; this addAction ["Tasking", {[] call ALiVE_fnc_C2MenuDef}]; this addAction ["Combat Support", {["radio"] call ALIVE_fnc_radioAction}]; ``` ##### Adding custom CQB zones ``` highhead [6:22 PM] Set up CQB as you would normally. highhead [6:23 PM] In Init.sqf put: [ALiVE_mil_CQB getVariable ["instances",[]]] call ALiVE_fnc_resetCQB; highhead [6:23 PM] then activate your zones with: [_pos,_radius,_CQB] spawn ALiVE_fnc_addCQBpositions. highhead [6:24 PM]whereas _CQB are instances of CQB modules. So the missionmaker f.e. can give it a name in editor, f.e. "CQB_regular" or "CQB_strategic" and highhead [6:24 PM]put it in like [_pos,_radius,[CQB_Regular]] spawn ALiVE_fnc_addCQBpositions. (edited) highhead [6:42 PM] f.e. A mission maker wants to have CQB in all strategic positions over the map from the beginning of the mission. Regular CQB in a specific location should be activated by trigger. - Add a CQB module on setting strategic and your other favorite settings (f.e. dominantFaction, density etc.). - Add a CQB module on setting regular and your other favorite settings (f.e. dominantFaction, density etc.). - Give the regular CQB module a name, f.e. myRegularCQBmodule put in init.sqf myRegularCQBmodule call ALiVE_fnc_resetCQB; In your trigger activation put: [_pos,_radius,[myRegularCQBmodule]] spawn ALiVE_fnc_addCQBpositions. You can also use position thisTrigger and triggerSize variables of the trigger. Just make sure it only fires once :simple_smile: highhead [6:44 PM] Additionally you can use [_pos,_radius,[CQB_Regular]] spawn ALiVE_fnc_removeCQBpositions to remove active CQB areas. ``` ### DCS World #### A-10C * [Wind correcting dummy bombs](http://forums.eagle.ru/showthread.php?t=66422) ## Misc ### Quotes Why did I take this nickname again? ``` [6-2-2014 23:42:36] Tupolov: Why are you dev/random [6-2-2014 23:43:45] Sacha Ligthert: ArmA didn't accept the Sha1sum of my full name as nickname.. [6-2-2014 23:44:02] Sacha Ligthert: So I took a unix device that other people asociated me with in the past. :) [6-2-2014 23:44:35] Sacha Ligthert: Sacha was getting kinda boring and ZombiTron would get confusing with scenarios containing zombies. [6-2-2014 23:45:10] Sacha Ligthert: And I test the limits of certain tools with a nickname containing characters like /'s. ;) [6-2-2014 23:52:26] Tupolov: you did! ``` I accidentally break things.. ``` [0:16:16] ARJay (ALiVE): Sacha stahp breaking our things, k thnks bai [0:17:10] Sacha LigthertSorry, I'm here to break^H^H^H^H^H test things. :) [0:20:56] Tupolov: /dev/random/break/your/shit/you/are/welcome [0:22:29] Tupolov: ;) ``` Pek says goodbye: ``` [1:47:13 PM] Manuel Pekelaer: Gents, Ik heb besloten me niet actief met de community meer te betrekken en niet meer mee te doen aan sessies for the time being [1:47:26 PM] Sacha Ligthert: Noted. [1:47:50 PM] * Sacha Ligthert kicked mpekelaer from the chat. ``` Hazey and I discuss our efforts: ``` [16:11:38] Sacha Ligthert: Haze, Am I the only one with the impression that our version of insurgency kickstarted groups into adopting alive? [16:14:00] Haze: I have seen a few larger groups run alive because of it. Would be interesting to get a download stat from tup when he is around. [16:16:22] Sacha Ligthert: Haze, we rock! :D ```