This file contains hidden or 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 UnityEngine; | |
| public class Folderise : MonoBehaviour | |
| { | |
| public string folderName = ""; | |
| void Start () | |
| { | |
| // add to folder | |
| if(folderName == "") |
This file contains hidden or 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
| -- https://github.com/Bradshaw/Fudge | |
| function love.load(arg) | |
| -- set save directory | |
| love.filesystem.setIdentity("fudge-test") | |
| -- initialise fudge texture packer | |
| fudge.set({ monkey = true }) | |
| -- prepare sprite packs | |
| if FORCE_FUDGE_REPACK | |
| or not love.filesystem.exists("background.png") |
This file contains hidden or 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
| #include "TrophySet.h" | |
| // Wow, you mean it actually gets worse?!? | |
| const bool (&TrophySet::GetTrophies() const)[N_TROPHIES] | |
| { | |
| return trophies; | |
| } |
This file contains hidden or 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
| #include "Achievements.h" | |
| #include "GameplayEvents.h" | |
| namespace Achievements | |
| { | |
| namespace // prefer anonymous namespaces of top-level 'static' keyword | |
| { | |
| void _unlock(size_t achievementId) | |
| { | |
| // code to implement achievement goes here |
This file contains hidden or 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
| // call lambda on all listeners | |
| static void _dispatch(std::function<void(GameplayEvents::Listener*)> listenerEvent) | |
| { | |
| for(size_t i = 0; i < _n_listeners; ++i) | |
| listenerEvent(_listeners[i]); | |
| } | |
| // a little syntactic sugar | |
| #define _DISPATCH(CALL, ...) { _dispatch([__VA_ARGS__](GameplayEvents::Listener* l){ l->CALL##(##__VA_ARGS__##); }); } |
This file contains hidden or 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
| var postObject = function(url, object) | |
| { | |
| var form_html = '<form action="' + url + '" method="post">'; | |
| for(var key in object) | |
| form_html += '<input type="text" name="' + key + '" value="' + object[key] + '" />'; | |
| form_html += '</form>'; | |
| var form = $(form_html); | |
| $('body').append(form); | |
| form.submit(); |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <button id="start_button" onclick="startButton(event)"> | |
| <img alt="Start" id="start_img" src="mic.gif"> | |
| </button> | |
| <div id="results"> | |
| <span class="final" id="final_span"></span> |
This file contains hidden or 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
| <html> | |
| <script type="text/javascript"> | |
| (function(){ | |
| var script = document.createElement('script'); | |
| script.type = "text/javascript"; | |
| // in real-life situations you'll want to check the query string or something to choose the script ;) | |
| script.src = (math.random() > 0.5) ? "a_script.js" : "other_script.js"; | |
| document.getElementsByTagName('head')[0].appendChild(script); | |
| })(); | |
| </script> |
This file contains hidden or 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
| bool Grid::IsBusy() | |
| { | |
| return ForEach([](int col, int row, Cell *cell) { return cell->IsBusy(); }); | |
| } | |
| bool Grid::ForEach(std::function<bool(int col, int row, Cell*)> f) | |
| { | |
| for (int col = 0; col < m_Width; ++col) | |
| for (int row = 0; row < m_Height; ++row) | |
| if(!f(col, row, m_Cells[col][row])) |
This file contains hidden or 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
| --[[ | |
| What if you want to pick a random option but you're not sure if that random option will be valid? | |
| Instead of doing a while loop and hoping that you'll eventually land on a valid option | |
| try shuffling the list of options and trying each one in this random order ;) | |
| W. | |
| --]] | |
| local shuffle = function(table) -- standard Fisher-Yates implementation | |
| for i = #table, 2, -1 do |