Update.update_all_updated(updates) # Update updated updates
By anon, 2018-05-25 16:45:41
 public void updateCurrency() {
        LOGGER.info("Update currencies");
        var ok = false;

        try {
            getExchangeRatesMechanism(getExchangeRatesProcessor());
            ok = true;
        } catch (Exception exception) {
            LOGGER.error(exception.getMessage(), exception);
        }

        if (ok) {
            LOGGER.info("The currencies were updated successfully!");
        }
    }
By halogenUnit, 2022-09-29 13:31:58
typedef signed int sint;
#define N 100
static int n = N;

inline int f(const int n, int& i, int* j, int t[2], int p=11)
{
    i*=i;
    (*j)--;
    
    if ( n<=0 )
    {
        cout << ::n << ">\n";
        return t[0];
    }
    else return f(n-1, i, j, t) + t[n];
}

int main()
{
    int n = 4;
    int x = 1U;
    sint y = 10;
    int (*fptr)(const int, int&, int*, int*, int) = f;

    int* t = new int[n];
    int& r = *(t+3);
    (*t) = 1;
    *(t+1) = 2;
    t[2] = 3;
    r = 4;

    int z = (*fptr)(5, x, &y, t, 12);    

    for(int i = 0; i < 2*n; i++)
    {
        if( i == n )
            continue;
        if( i > n )
            break;
        cout << t[i] << "\n";
    };
    cout << x << ", " << y << ", " << z << "\n";
    
    delete[] t;
}

This is what my professor gave as part of the final exam. The purpose of giving us this code was to get us used to seeing different ways the C++ syntax can be used and figure out what the output is.

By Anonymous, 2023-02-02 21:29:11
var i = 0

for (var n in array) { 
    i+=1
    // ...
}
By PureJavascript, 2023-02-11 11:08:33
var lightBox_ReplaceSelectsWithSpans = function()
{
	var selects = document.getElementsByTagName('select');
	for (var i = 0; i < selects.length; i++) {
		var select = selects[i];
		if (select.clientWidth == 0 || select.clientHeight == 0 || 
			select.nextSibling == null || select.nextSibling.className == 'selectReplacement') {
			continue;
		}
			
		var span = document.createElement('span');
		// this would be "- 3", but for that appears to shift the block that contains the span 
		//   one pixel down; instead we tolerate the span being 1px shorter than the select
		span.style.height = (select.clientHeight - 4) + 'px';
		span.style.width = (select.clientWidth - 6) + 'px';
		span.style.display = 'inline-block';
		span.style.border = '1px solid rgb(200, 210, 230)';
		span.style.padding = '1px 0 0 4px';
		span.style.fontFamily = 'Arial';
		span.style.fontSize = 'smaller';
		span.style.position = 'relative';
		span.style.top = '1px';
		span.className = 'selectReplacement';
		
		span.innerHTML = select.options[select.selectedIndex].innerHTML ;//+ 
			//'<img src="custom_drop.gif" alt="drop down" style="position: absolute; right: 1px; top: 1px;" />';
		
		select.cachedDisplay = select.style.display;
		select.style.display = 'none';
		select.parentNode.insertBefore(span, select.nextSibling);
	}
};
By Anonymous, 2023-03-29 16:59:15
import cv2
import numpy as np

cap = cv2.VideoCapture(0)

while (1):

    _, frame = cap.read()

    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    lower_green = np.array([40, 50, 50])
    upper_green = np.array([80, 102, 200])

    # Threshold the HSV image to get only green colors
    mask = cv2.inRange(hsv, lower_green, upper_green)

    total_pixels = mask.shape[0] * mask.shape[1]
    print "Number of pixels: %", total_pixels

    pixel_counter = 0
    x_counter = 0
    y_counter = 0
    for y in xrange(640):
        for x in xrange(480):
            pixel = mask[x, y]
            if pixel == 255:
                pixel_counter += 1
                x_counter += x
                y_counter += y
    x_center = x_counter / pixel_counter
    y_center = y_counter / pixel_counter
    print x_center, y_center

    cv2.line(frame, (x_center+15, y_center), (x_center+2, y_center), (235, 218, 100), 1)
    cv2.line(frame, (x_center-15, y_center), (x_center-2, y_center), (235, 218, 100), 1)
    cv2.line(frame, (x_center, y_center+15), (x_center, y_center+2), (235, 218, 100), 1)
    cv2.line(frame, (x_center, y_center-15), (x_center, y_center-2), (235, 218, 100), 1)

    cv2.circle(frame, (x_center, y_center), 4, (235, 218, 100), 2)

    cv2.imshow('frame', frame)

    k = cv2.waitKey(5) & 0xFF
    if k == 27:
        break

cv2.destroyAllWindows()

track the green color

By Vik.victory, 2017-06-23 19:11:14
#include <iostream>
#define OPEN_PARENTHESIS (
#define CLOSE_PARENTHESIS )
#define OPEN_BRACES {
#define CLOSE_BRACES }
#define INTEGER int
#define STANDARD_LIB std::
#define CONSOLE_OUT cout
#define ANGLE_BRACKETS <<
#define MESSAGE "Hello World\n"
#define SEMI ;
#define CLASS_NAME main

INTEGER CLASS_NAME OPEN_PARENTHESIS CLOSE_PARENTHESIS OPEN_BRACES
STANDARD_LIB CONSOLE_OUT ANGLE_BRACKETS MESSAGE SEMI
CLOSE_BRACES

Everything is defined

By Anonymous, 2021-06-28 01:46:44
@EventHandler
	public void onCpUse(PlayerMoveEvent e) {
		Player player = e.getPlayer();
		if(Main.main.state != Gamestate.JUMP) return;
		if(!Main.main.alive.contains(player)) return;
		Location loc = e.getPlayer().getLocation();
		  loc.setY(loc.getY() -1);
		  Block standingOnBlock = loc.getBlock();
		  int currentCP = Main.main.checkpointTracker.get(player);
			int nextCP = currentCP+1;
		  if(standingOnBlock.getType() == Material.EMERALD_BLOCK) {
			  Main.main.lm.setLocation(Main.main.map + "x" + nextCP + "x" + player.getName(), player.getLocation());
			  standingOnBlock.setType(Material.BEDROCK);
				giveCPEquip(player, nextCP);
					Main.main.checkpointTracker.put(player, nextCP);
					Main.main.scoreboard.setIngameScoreboard(player);
					player.sendMessage(Main.main.pr + "�aDu hast den " + nextCP + ". Checkpoint erreicht!");
					if(Main.main.particleTracker.containsKey(player)) {
						player.spawnParticle(Main.main.particleTracker.get(player), player.getLocation(), 10);
					}
			 		player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 10, 1);
		  }
	}
	public void giveCPEquip(Player p, int cp) {
		Inventory i = p.getInventory();
		ItemStack cp1Helmet = Main.main.utils.create(Material.LEATHER_HELMET, 1);
		ItemStack cp1Chest = Main.main.utils.create(Material.LEATHER_CHESTPLATE, 1);
		ItemStack cp1Leggings = Main.main.utils.create(Material.LEATHER_LEGGINGS, 1);
		ItemStack cp1Boots = Main.main.utils.create(Material.LEATHER_BOOTS, 1);
		
		ItemStack cp2Sword = Main.main.utils.createSharp1Item(Material.STONE_SWORD, 1);
		
		ItemStack cp3Apples = Main.main.utils.create(Material.GOLDEN_APPLE, 3);
		
		ItemStack cp4Chest = Main.main.utils.create(Material.CHAINMAIL_CHESTPLATE, 1);
		ItemStack cp4Leggings = Main.main.utils.create(Material.CHAINMAIL_LEGGINGS, 1);
		
		ItemStack cp5Helmet = Main.main.utils.create(Material.IRON_HELMET, 1);
		ItemStack cp5Boots = Main.main.utils.create(Material.IRON_BOOTS, 1);
		
		//6 Add extra Herzen
		
		ItemStack cp7Sword = Main.main.utils.create(Material.DIAMOND_SWORD, 1);
		
		ItemStack cp8Sword = Main.main.utils.create(Material.SHIELD, 1);
		
		
		ItemStack cp1Helmet1 = Main.main.utils.create(Material.DIAMOND_HELMET, 1);
		ItemStack cp1Chest1 = Main.main.utils.create(Material.DIAMOND_CHESTPLATE, 1);
		ItemStack cp1Leggings1 = Main.main.utils.create(Material.DIAMOND_LEGGINGS, 1);
		ItemStack cp1Boots1 = Main.main.utils.create(Material.DIAMOND_BOOTS, 1);
		
		ItemStack cp2Sword1 = Main.main.utils.createSharp1Item(Material.DIAMOND_SWORD, 1);
		
		ItemStack cp3Apples1 = Main.main.utils.create(Material.SHIELD, 1);
		
		ItemStack cp4Leggings1 = Main.main.utils.create(Material.NETHERITE_LEGGINGS, 1);
		
		ItemStack cp5Helmet1 = Main.main.utils.create(Material.NETHERITE_HELMET, 1);
		ItemStack cp5Boots1 = Main.main.utils.create(Material.NETHERITE_BOOTS, 1);
		
		//6 Add extra Herzen
		
		ItemStack cp7Sword1 = Main.main.utils.create(Material.NETHERITE_CHESTPLATE, 1);
		
		ItemStack cp8Sword1 = Main.main.utils.createSharp1Item(Material.NETHERITE_SWORD, 1);
		
		
		ItemStack cp1Helmet2 = Main.main.utils.create(Material.GOLDEN_HELMET, 1);
		ItemStack cp1Chest2 = Main.main.utils.create(Material.GOLDEN_CHESTPLATE, 1);
		ItemStack cp1Leggings2 = Main.main.utils.create(Material.GOLDEN_LEGGINGS, 1);
		ItemStack cp1Boots2 = Main.main.utils.create(Material.GOLDEN_BOOTS, 1);
		
		ItemStack cp2Sword2 = Main.main.utils.createSharp1Item(Material.STONE_SWORD, 1);
		
		ItemStack cp3Apples2 = Main.main.utils.create(Material.GOLDEN_APPLE, 3);
		ItemStack cp3Apple2 = Main.main.utils.create(Material.SHIELD, 1);
		
		ItemStack cp4Leggings2 = Main.main.utils.create(Material.IRON_LEGGINGS, 1);
		
		ItemStack cp5Helmet2 = Main.main.utils.create(Material.IRON_HELMET, 1);
		ItemStack cp5Boots2 = Main.main.utils.create(Material.IRON_BOOTS, 1);
		
		//6 Add extra Herzen
		
		ItemStack cp7Sword2 = Main.main.utils.create(Material.IRON_CHESTPLATE, 1);
		
		ItemStack cp8Sword2 = Main.main.utils.createSharp1Item(Material.IRON_SWORD, 1);
		
		
		
		if(!Main.main.random) {
		if(Main.main.rn ==0) {
		if(cp == 1) {
			i.addItem(cp1Helmet);
			i.addItem(cp1Chest);
			i.addItem(cp1Leggings);
			i.addItem(cp1Boots);
		}else if(cp == 2) {
			i.addItem(cp2Sword);
		}else if(cp == 3) {
			i.addItem(cp3Apples);
		}else if(cp == 4) {
			i.addItem(cp4Chest);
			i.addItem(cp4Leggings);
		}else if(cp == 5) {
			i.addItem(cp5Helmet);
			i.addItem(cp5Boots);
		}else if(cp == 6) {
			p.setMaxHealth(24);
			p.sendMessage(Main.main.pr + "�aDu hast zwei Extraherzen erhalten!");
		}else if(cp == 7) {
			i.addItem(cp7Sword);
		}else if(cp == 8) {
			i.addItem(cp8Sword);
			if(Main.main.fallTracker.get(p) == 0) {
				p.sendMessage(Main.main.pr + "Du hast das Ziel ohne JumpFail erreicht!");
				p.getInventory().addItem(Main.main.utils.create(Material.DIAMOND_HELMET, 1));
			}
			Bukkit.broadcastMessage(Main.main.pr + "�5" + p.getName() + " �a hat das Ziel erreicht!");
			Main.main.cd.cancelIngameTask();
			Main.main.cd.startDeathmatchCD();
		}
	}else if(Main.main.rn == 1) {
		if(cp == 1) {
			i.addItem(cp1Helmet1);
			i.addItem(cp1Chest1);
			i.addItem(cp1Leggings1);
			i.addItem(cp1Boots1);
		}else if(cp == 2) {
			i.addItem(cp2Sword1);
		}else if(cp == 3) {
			i.addItem(cp3Apples1);
		}else if(cp == 4) {
			i.addItem(cp4Leggings1);
		}else if(cp == 5) {
			i.addItem(cp5Helmet1);
			i.addItem(cp5Boots1);
		}else if(cp == 6) {
			p.setMaxHealth(24);
			p.sendMessage(Main.main.pr + "�aDu hast zwei Extraherzen erhalten!");
		}else if(cp == 7) {
			i.addItem(cp7Sword1);
		}else if(cp == 8) {
			i.addItem(cp8Sword1);
			if(Main.main.fallTracker.get(p) == 0) {
				p.sendMessage(Main.main.pr + "Du hast das Ziel ohne JumpFail erreicht!");
				p.getInventory().addItem(Main.main.utils.create(Material.GOLDEN_APPLE, 10));
			}
			Bukkit.broadcastMessage(Main.main.pr + "�5" + p.getName() + " �a hat das Ziel erreicht!");
			Main.main.cd.cancelIngameTask();
			Main.main.cd.startDeathmatchCD();
		}
	}else if(Main.main.rn == 2) {
		if(cp == 1) {
			i.addItem(cp1Helmet2);
			i.addItem(cp1Chest2);
			i.addItem(cp1Leggings2);
			i.addItem(cp1Boots2);
		}else if(cp == 2) {
			i.addItem(cp2Sword2);
		}else if(cp == 3) {
			i.addItem(cp3Apples2);
			i.addItem(cp3Apple2);
		}else if(cp == 4) {
			i.addItem(cp4Leggings2);
		}else if(cp == 5) {
			i.addItem(cp5Helmet2);
			i.addItem(cp5Boots2);
		}else if(cp == 6) {
			p.setMaxHealth(24);
			p.sendMessage(Main.main.pr + "�aDu hast zwei Extraherzen erhalten!");
		}else if(cp == 7) {
			i.addItem(cp7Sword2);
		}else if(cp == 8) {
			i.addItem(cp8Sword2);
			if(Main.main.fallTracker.get(p) == 0) {
				p.sendMessage(Main.main.pr + "Du hast das Ziel ohne JumpFail erreicht!");
				p.getInventory().addItem(Main.main.utils.create(Material.GOLDEN_APPLE, 10));
			}
			Bukkit.broadcastMessage(Main.main.pr + "�5" + p.getName() + " �a hat das Ziel erreicht!");
			Main.main.cd.cancelIngameTask();
			Main.main.cd.startDeathmatchCD();
		}	
	}
		}else {
		    Random random = new Random();
		    List<Material> materials = Arrays.asList(Material.values());
		    int size = materials.size()-1;
		    Material ran = materials.get(random.nextInt(size));
		    p.getInventory().addItem(new ItemStack(ran, 1));
		    if(cp == 8) {
		    	if(Main.main.fallTracker.get(p) == 0) {
					p.sendMessage(Main.main.pr + "Du hast das Ziel ohne JumpFail erreicht!");
					p.getInventory().addItem(Main.main.utils.create(Material.DIAMOND_HELMET, 1));
				}
				Bukkit.broadcastMessage(Main.main.pr + "�5" + p.getName() + " �a hat das Ziel erreicht!");
				Main.main.cd.cancelIngameTask();
				Main.main.cd.startDeathmatchCD();
		    }
		}
	}

This beautiful code snippet was found in one of the repositories of people who sell their products on Fiverr. As you may have noticed only the functionally of code is beautiful but also the formatting style.

By Anonymous, 2021-07-06 23:38:00
int minimum(int a, int b, int c){
  int mini =a*b*c;
  int iterator=0;
  int test[3];
  test[0]=a;
  test[1]=b;
  test[2]=c;
  for (iterator=0;iterator<3;iterator++){
    if (test[iterator]<mini){
      mini=test[iterator];
    }
  }
  return mini;
}

I hope that your 3 numbers aren't larger than 1290!

By Another random student of algorithms., 2017-12-14 01:28:18
public static int[] xxx(String filename) throws IOException{
	int[] f = new int[26];
	BufferedReader in = new BufferedReader(new FileReader(filename));
	String line;
	while((line = in.readLine()) != null){
		line = line.toUpperCase();
		for(char ch:line.toCharArray()){
			if(Character.isLetter(ch)){
				f[ch - 'A']++;
			}
		}
	}
	in.close();
	return f;
}
By Anonymous, 2017-12-15 16:08:38
> var x = 3;
> '5' + x - x
50
> '5' - x + x
5 // Because fuck math

JS is simply. Oh, wait...

By mademan, 2015-11-18 13:50:39
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class StoryOfMyLife : MonoBehaviour
{
    void OnDestory()
    {
        Debug.Log("  Directed by  ");
        Debug.Log("ROBERT B. WEIDE");
    }
}

For Unity developers only

By SanSanych, 2020-09-25 21:22:53
if (currentDay.day() !== MONDAY) {
    do {
        currentDay = this.$moment(currentDay).subtract(1, 'days');
        days.unshift(currentDay);
    } while (currentDay.day() !== MONDAY);
}
By Anonymous, 2017-10-14 18:44:20
form = JSON.parse(JSON.stringify(this.mobilityDistanceForm.getRawValue()));
By tralaladidou, 2019-07-15 20:41:51
public static int[] sleepSort(int... args) {
        final int[] sorted = new int[args.length];
        final AtomicInteger index = new AtomicInteger(0);
        List<Thread> threads = new ArrayList<Thread>(0);
        for (int i = 0; i < args.length; i++) {
            final int x = i;
            Thread sorter = new Thread(() -> {
                try {
                    Thread.sleep(args[x]);
                } catch (InterruptedException ex) { 
                    // shrug
                }
                sorted[index.getAndIncrement()] = args[x];
            });
            sorter.setDaemon(true);
            sorter.start();
            threads.add(sorter);
        }
        try {
            for (Thread t : threads) { t.join(); }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return sorted;
    }

Takes an unsorted array of integers, sorts by sleeping for the int value of each item in the array and then writing that into the resulting sorted array. Big-O analysis is... difficult.

By Sum YungGui, 2017-12-12 17:10:56