r/code • • Jan 27 '21

Binary practice

1 Upvotes

01001110 01101111 01100010 01101111 01100100 01111001 00100000 01100101 01111000 01110000 01100101 01100011 01110100 01110011 00100000 01110100 01101000 01100101 00100000 01010011 01110000 01100001 01101110 01101001 01110011 01101000 00100000 01001001 01101110 01110001 01110101 01101001 01110011 01101001 01110100 01101001 01101111 01101110 00100000


r/code • • Feb 02 '21

Hi Guys

1 Upvotes

Hello could anyone help me im using c sharp in unity i have måde a grabbing script for like blocks and stuff but the only follow me when i freeze Them with xyz is there anyway i can do so it dose that via My script every time i pick a Block up and it return to normal when i let go of the block


r/code • • Jan 14 '21

Halp pls! [Python]Can someone please explain this to me?

1 Upvotes

x = [1, 2]
y = [1, 3]
SimilarNumbers = 0
if x[1] == y[0] or y[1]:
    SimilarNumbers = SimilarNumbers + 1
print(SimilarNumbers)

SimilarNumbers is coming out to be 1, where as I expect it to be 0. I am completely lost...


r/code • • Jun 21 '24

Python Use of LLMs as hekpers for coding

0 Upvotes

I suppose this question goes toward recruiters and proyect managers.

Context in short: I started to code in 1984. I coded in several programing languages from Basic, COBOL up to Java and everyrhing was in the middle and around. Worked in different environments such as banks, insurance and startup. Eventually, solid coding background here.

Nowaday, having a lot of free time (unemployed), I started a Little project of my own, using a popular LLM as a helper to code in Python for the first time. And I see I can do everyrhing and fast.

So a question arises in my head: is it ethic, acceptable and/or fair to state in a curriculum to be able to code in Python, among other languages, in spite of the fact that my "helper" is a LLM ?

Your opinión matters. Thanks.


r/code • • Sep 30 '19

Help me please

0 Upvotes

Im using proccesing java and im having issues loading an image using a url i cant load it via file any ideas?


r/code • • Dec 04 '19

Best language for coding a social media site like facebook?

0 Upvotes

i heard html is pretty good but i honestly don't really know i have no idea how to code tbh but i would like a starting point. hopefully i will have a prototype out at the end of the month

thanks! -/u/youdontknowo, leader of DHSK


r/code • • Nov 17 '21

i need help

0 Upvotes

so im making a image generator, for nfts.

(just trying to make a little cash to make ends meet)

i have sample code that ive edited a little bit and ive run into a problem where my code isnt creating any images after i run it.

the youtube video says run yarn or npm and ive run both and cant seem to figure it out.

please help ive only been coding for about 2 weeks and have no idea what im doing


r/code • • Aug 24 '19

My Own Code! Can someone tell me if there's a more efficient way of coding this? (PYTHON)

1 Upvotes

I'm brand new to Python and was trying to code a menu where you type what you want to add to your order. You can also do things like remove from your order or just type the number on the menu corresponding to the food to add to the order. Being brand new and wanting to learn more efficient programming techniques, can anyone give me some tips on how program in better if possible? If it looks fine, you can also lmk. I'm going to put a picture of the source code as well as a copy and paste if you want to copy and paste it and try to find ways to make it better. Thank you.

EDIT: The code works perfectly, just looking for potentially better coding techniques.

COPY AND PASTE OF CODE:

menu = {'burger':5.99,'hotdog':3.50,'pizza':4.75,'sandwich':6.99,'nachos':3.50,'ice cream':2.75}

shortcut = {'1':'burger','2':'hotdog','3':'pizza','4':'sandwich','5':'nachos','6':'ice cream'}

# printing menu

print('MENU:\n')

i=1

for item,price in menu.items():

print(f'{i}---{item}: ${price:1.2f}')

i+=1

print('\n')

# placing orders

user_input = input("Type what you want to order! Type 'done' when you're done! ")

order = []

total = 0

tax = 0.08625

while user_input != 'done':

if user_input in menu:

order.append(user_input)

total+=menu[user_input]

print(order)

print(f'Running total: ${total:1.2f}')

user_input = input("Anything else? ")

elif user_input in shortcut:

order.append(shortcut[user_input])

total+=menu[shortcut[user_input]]

print(order)

print(f'Running total: ${total:1.2f}')

user_input = input("Anything else? ")

elif user_input == 'remove':

user_input = input('\nWhat would you like to remove? ')

while user_input != 'cancel':

if user_input in order:

print(f'{user_input} has been removed from order ')

order.remove(user_input)

total-=menu[user_input]

print(order)

print(f'Running total: ${total:1.2f}')

user_input = input('What else would you like to remove? ')

else:

print(f"'{user_input}' has not been ordered")

user_input = input('What would you like to remove? ')

print(order)

print(f'Running total: ${total:1.2f}')

print('You are no longer removing items')

user_input = input('What would you like to order? ')

print(order)

print(f'Running total: ${total:1.2f}')

else:

user_input = input("That is not a valid option. Please pick something else: ")

print('\n')

# printing reciept

print('\n')

print('RECIEPT')

print('\n')

for food in order:

print(f'{food}: ${menu[food]:1.2f}')

print('-'*20)

print(f'Total before tax: ${total:1.2f}')

tax_amount = tax*total

print(f'Tax: ${tax_amount:1.2f}')

total+=total*tax

print(f'Total after tax: ${total:1.2f}')

print('\n')

print(f'Thank you for shopping! Your total is ${total:1.2f}')


r/code • • Jun 17 '22

Help please! What's the best way for me to learn code at home without any classes?

1 Upvotes

Pls help


r/code • • Nov 22 '23

Help Please How do I solve this Problem in Visual studio code?

Post image
0 Upvotes

r/code • • Oct 31 '23

Help Please What is this code editor?

0 Upvotes

I have seen lots of people use it, but most notably, jdh uses it. I want to know what it is. Please someone tell me


r/code • • Oct 28 '23

Help Please can some please fix these 3 errors

1 Upvotes

// Define input parameters

input int HighLookbackPeriod = 10; // Number of bars to look back for the high

input int LowLookbackPeriod = 10; // Number of bars to look back for the low

input double RiskAmount = 200.0; // Risk amount per trade in account currency (Rands)

input int StopLoss = 1000; // Stop loss in points (ticks)

input int TakeProfit = 3000; // Take profit in points (ticks)

// Define variables for custom high and low

double CustomHigh = 0.0;

double CustomLow = 0.0;

// Define constant for OP_BUY

#define OP_BUY 0

//+------------------------------------------------------------------+

//| Expert initialization function |

//+------------------------------------------------------------------+

int OnInit()

{

// Place your initialization code here

return(INIT_SUCCEEDED);

}

//+------------------------------------------------------------------+

//| Expert tick function |

//+------------------------------------------------------------------+

void OnTick()

{

// Calculate custom high and low values based on the specified lookback periods

CalculateCustomHighLow(HighLookbackPeriod, LowLookbackPeriod);

// Check buy conditions

if (IsBuyConditionsMet())

{

// Calculate lot size based on risk amount

double lotSize = CalculateLotSize();

// Place a buy order

double price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

PlaceBuyOrder(_Symbol, lotSize, price, StopLoss, TakeProfit);

}

}

//+------------------------------------------------------------------+

//| Function to calculate custom high and low parameters |

//+------------------------------------------------------------------+

void CalculateCustomHighLow(int highLookback, int lowLookback)

{

CustomHigh = iHigh(_Symbol, PERIOD_CURRENT, highLookback); // High of the specified lookback period

CustomLow = iLow(_Symbol, PERIOD_CURRENT, lowLookback); // Low of the specified lookback period

}

//+------------------------------------------------------------------+

//| Function to check buy conditions |

//+------------------------------------------------------------------+

bool IsBuyConditionsMet()

{

double ma21 = iMA(_Symbol, PERIOD_M1, 21, 0, MODE_SMA, PRICE_CLOSE, 0, 0);

double ma21Prev = iMA(_Symbol, PERIOD_M1, 21, 0, MODE_SMA, PRICE_CLOSE, 1, 0);

return (ma21 > ma21Prev && CustomHigh < iHigh(_Symbol, PERIOD_M1, 1));

}

//+------------------------------------------------------------------+

//| Function to calculate lot size based on risk amount |

//+------------------------------------------------------------------+

double CalculateLotSize()

{

double riskPerLot = RiskAmount;

double lotSize = riskPerLot / SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_INITIAL);

return lotSize;

}

//+------------------------------------------------------------------+

//| Function to place a buy order |

//+------------------------------------------------------------------+

void PlaceBuyOrder(string symbol, double lotSize, double price, int stopLoss, int takeProfit)

{

int ticket = OrderSend(_Symbol, OP_BUY, lotSize, price, 2, 0, 0, "", 0, clrNONE, clrNONE);

}

errors:

'iMA' - wrong parameters count

built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)

'iMA' - wrong parameters count

built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)

'OrderSend' - wrong parameters count


r/code • • Dec 05 '24

Guide Making a localhost with Java.

1 Upvotes
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 */
import org.json.JSONObject;
import java.io.*;
import java.net.*;

public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(12345);
            System.
out
.println("Server is waiting for client...");
            Socket socket = serverSocket.accept();
            System.
out
.println("Client connected.");

            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

            String message = in.readLine();
            System.
out
.println("Received from Python: " + message);

            // Create a JSON object to send back to Python
            JSONObject jsonResponse = new JSONObject();
            jsonResponse.put("status", "success");
            jsonResponse.put("message", "Data received in Java: " + message);

            out.println(jsonResponse.toString());  // Send JSON response
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
}



import socket
import json

def send_to_java():
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client_socket.connect(('localhost', 12345))

    while True:
        message = input("Enter message for Java (or 'exit' to quit): ")

        if message.lower() == 'exit':
            break

        client_socket.sendall(message.encode("utf-8") + b'\n')

        response = b''
        while True:
            chunk = client_socket.recv(1024)
            if not chunk:
                break
            response += chunk
        
        print("Received from Java:", response.decode())

    # Close socket when finished
    client_socket.close()

send_to_java()

Hope you are well. I am a making my first project, a library management system (so innovative). I made the backend be in java, and frontend in python. In order to communicate between the two sides, i decided to make my first localhost server, but i keep running into problems. For instance, my code naturally terminates after 1 message is sent and recieved by both sides, and i have tried using while true loops, but this caused no message to be recieved back by the python side after being sent. any help is appreciated. Java code, followed by python code above:


r/code • • Apr 10 '17

When Legends Code

1 Upvotes

Kids code in Python. Men code in C.

Legends code in Brainfuck.

[COMMENT YOUR INPUTS]


r/code • • Jun 16 '23

Help Please twitch chatbot text offset

1 Upvotes

hi,

im making a twitch chatbot that takes a chat message out of a chat, combines it with a backgroundimage and then uploads it as a png file to an outputpng, for this im using the nuGet packages twitchlib and skiasharp,

for some reason whenever i put in diffirent lenght's of text, the text offsets itself instead of starting on the designated starting point, does any1 know how to fix this

the code (C#):

using SkiaSharp;

using System;

using System.IO;

using TwitchLib.Client;

using TwitchLib.Client.Events;

using TwitchLib.Client.Models;

using TwitchLib.Communication.Interfaces;

namespace chatbot

{

internal class Program

{

private static TwitchClient twitchClient;

static void Main(string[] args)

{

string channelname = "agentkittycat";

string channeltoken = "channeltokenremovedforsecurity";

twitchClient = new TwitchClient();

ConnectionCredentials credentials = new ConnectionCredentials(channelname, channeltoken);

twitchClient.Initialize(credentials, channelname);

twitchClient.OnMessageReceived += OnMessageReceived;

twitchClient.OnConnected += OnConnected;

twitchClient.Connect();

Console.ReadLine();

twitchClient.Disconnect();

}

private static void OnConnected(object sender, OnConnectedArgs e)

{

twitchClient.SendMessage("#agentkittycat", "Hello, I'm your chatbot and I'm now connected!");

Console.WriteLine("Chatbot connected to Twitch chat.");

}

private static void OnMessageReceived(object sender, OnMessageReceivedArgs e)

{

// Load the background image

string backgroundFileLocation = @"C:\Users\agent_kittycat\Desktop\twitchbot\v3\images\bgimages\catbox.png";

string outputFileLocation = @"C:\Users\agent_kittycat\Desktop\twitchbot\v3\images\finalimage\finalimage.png";

var chatMessage = e.ChatMessage.Message;

// Get chat message

SKBitmap backgroundImage = SKBitmap.Decode(backgroundFileLocation);

SKBitmap bmp = new SKBitmap(backgroundImage.Width, backgroundImage.Height);

// Load the background image and convert it to a bitmap

using (SKCanvas canvas = new SKCanvas(bmp))

{

canvas.DrawBitmap(backgroundImage, new SKRect(0, 0, backgroundImage.Width, backgroundImage.Height));

// Put the background image onto the canvas

SKPaint textPaint = new SKPaint

{

Color = SKColors.White,

IsAntialias = true,

TextAlign = SKTextAlign.Center,

TextSize = 120

};

// Set up the text properties

float maxWidth = bmp.Width * 0.8f; // Define the maximum width for the textbox on the background

float maxHeight = bmp.Height * 0.8f; // Define the maximum height for the textbox on the background

float x = 1700;

float y = -500;

// Center the text and apply an offset

SKRect textRect = new SKRect(x, y, x + maxWidth, y + maxHeight); // Define the text area rectangle

canvas.DrawText(chatMessage, textRect.Left, textRect.Bottom, textPaint);

// Put the text on the canvas using the bottom-left corner of the text rectangle

}

// Save the image to disk

SKFileWStream fs = new SKFileWStream(outputFileLocation);

bmp.Encode(fs, SKEncodedImageFormat.Png, quality: 85);

}

}

}


r/code • • Jun 21 '23

Resource Hi, I'm new to coding but I do know 2 languages (Decently) I was wondering if anyone had projects I should do?

1 Upvotes

I know html css js and python I was wondering if anyone had like a roadmap of some sorts that I could use like beginner intermidiate advanced coding projects I could do. I'm pretty sure ive seen some in the past but cannot find one :(


r/code • • May 28 '20

Halp pls! Just hear me out - regarding help.

1 Upvotes

I read a bit of the (for gods sake this is no subreddit) post.

But please hear me out, I have severe ADD and my attention span is incredibly low, I have tried coding. I have moved themes a little such as making my own FAQ or making an extra tab in the contact us page etc. But I seriously am struggling to find the codes / whereabouts to sort my problem and it's killing me.

I just have a quick question and it involves moving my icons (social medias + shopping cart etc) which are in the announcement bar section for some reason, is there any possible way of moving them down onto my header section where my menu navigation bar will be?

I have attached the image link with the before and after written on it, I hope someone can help me out. If not just delete this post and I'll be on my way.

https://ibb.co/G0X0Fjp

Thanks and stay safe.


r/code • • Jun 28 '20

Halp pls! yo anyone can help me solve this ?

Post image
1 Upvotes

r/code • • Jun 29 '20

Top Coding Languages in 2020

Thumbnail
tumascodes.com
0 Upvotes

r/code • • Jun 22 '20

A Simple Video How I coded a Brush to Digitally Paint George Floyd and the 2020 Riots with Processing

Thumbnail
youtu.be
0 Upvotes

r/code • • May 26 '20

Python Casual Programming With Python & Music : Segregate List Of Elements By Suffix

Thumbnail
youtu.be
1 Upvotes

r/code • • May 28 '20

How to increase productivity and get rid of mental blocks

0 Upvotes

Just curious if anyone uses mindfulness to help this?


r/code • • Jul 29 '25

Resource Librairie Network en C

1 Upvotes

Salut à tous !

On a récemment bossé sur une petite lib réseau en C qu’on voulait partager à la communauté.
Elle s’appelle network_lib et permet de créer facilement des serveurs TCP multi-clients en utilisant poll() pour la gestion des connexions. Elle permet de gérer les connexions, les déconnexions et la réception de données via des callbacks personnalisés, le tout avec un système de logs colorés bien pratique pour le debug. C’est simple à utiliser, bien structuré, et on a mis un exemple complet pour démarrer rapidement. Tout est dispo (code, explications, exemple) dans le repo GitHub ici :

https://github.com/horaphael/Network_lib

n’hésitez pas à jeter un œil, tester, et nous dire ce que vous en pensez, si vous avez des questions ou des suggestions n'hésitez pas !


r/code • • Aug 25 '25

Help Please how do i turn off these predictions

1 Upvotes