Posts

Showing posts from June, 2014

python - how to append data to existing LMDB? -

i have around 1 million images put in dataset 10000 @ time appended set. i"m sure map_size wrong ref article used line create set env = lmdb.open(path+'mylmdb', map_size=int(1e12) use line every 10000 sample write data file x , y placeholders data put in lmdb. env = create(env, x[:counter,:,:,:],y,counter) def create(env, x,y,n): env.begin(write=true) txn: # txn transaction object in range(n): datum = caffe.proto.caffe_pb2.datum() datum.channels = x.shape[1] datum.height = x.shape[2] datum.width = x.shape[3] datum.data = x[i].tostring() # or .tostring() if numpy < 1.9 datum.label = int(y[i]) str_id = '{:08}'.format(i) # encode essential in python 3 txn.put(str_id.encode('ascii'), datum.serializetostring()) #pdb.set_trace() return env how can edit code such new data added lmdb , not replaced prese

c# - How to bind an `ObservableCollection` to Grid with Rows/Columns specified in the objects? -

i have inside grid: <ellipse grid.row="{binding path=game.tiles[2].row}" grid.column="{binding path=game.tiles[2].column}" fill="{binding game.tiles[2].fillcolor}" stroke ="{staticresource tilestroke}"></ellipse> how enumerate on 24 objects without typing 24 times? in order have list/collection of objects displayed, need employ "itemscontrol" of sorts. in case, following fragment might of help: <itemscontrol itemssource="{binding game.tiles}"> <itemscontrol.itemspanel> <itemspaneltemplate> <grid> <grid.rowdefinitions> <rowdefinition height="*"/> <rowdefinition height="*"/> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndef

CakePHP 3 associates between two tables -

i trying create associations between 2 models ( servers , application_endpoints) tables in cakephp 3. achieve data application_endpoints table servers model. in view can access data. server can have multiple vips , endpoints in application_endpoints table , using hasmany association. in serverstable.php added below code: $this->hasmany('applicationendpoints', [ 'foreignkey' => 'server_id', 'dependent' => true ]); so when browse server view page , click on debug kit inside variable tab, dont see joins. see list of servers in array, each server in array doesnt show relationships application_endpoints table. please comment , let me know if not clear, linking sqlfiddle mysql schema. update 1 i tried code in serverstable.php: $this->belongsto('applicationendpoints', [ 'bindingkey' => 'server_id', 'jointype' => 'inner', ]

python - How to keep random.choice() from rechecking itself -

today writing code in give addition or subtraction of integer problems. example: from random import randint, choice while true: value_1 = randint(-9,9) value_2 = randint(-9,9) lol = choice(['+', '-']) number = input("what %s %s %s" % (value_1, lol, value_2)) if lol == "+": try: number_x = int(number) except valueerror: print("you did not enter number silly goose") else: if number_x == value_1 + value_2: print("you got answer right. job!!") else: print("incorrecto padwan. still have learn") elif lol == "-": try: number_x = int(number) except valueerror: print("you did not enter number silly goose") else: if number_x == value_1 -

xml - Where is the extra space coming from? (XSLT) -

i'm generating hyperlinks xslt , keep getting spaces @ end of linked words. my xml looks this: the last word needs <url id="1">link</url>. the link concatenated, using @id. here's xslt: <xsl:template match="//url"> <a href="../mainsite.html{@id}"><xsl:copy-of select="."/></a> </xsl:template> for reason, generates link on word 'link', adds space after it, though there no space between url tags. if switch out xsl:copy-of plain string problem goes away. eg: <xsl:template match="//url"> <a href="../mainsite.html{@id}">string</a> </xsl:template> where on earth space coming from? it's driving me mad, because link that's followed punctuation looks screwy. should looking @ track down problem? thank can help. <xsl:template match="//url"> <a href="../mainsite.html{@id}"><

How to set toolbar title in center in android in JAVA -

this question has answer here: android: how center title in toolbar 12 answers i know layout way set toolbar title in center. (have textview in toolbar) i looking java way same. toolbar layout <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorprimary" android:minheight="?attr/actionbarsize"> </android.support.v7.widget.toolbar> this how setting toolbar title in activity: toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); getsupportactionbar().settitle("my orders"); getsupportactionbar().setdisplayhomeasupenabled(true); title left aligned default. is there way (without changing layout) make title centered aligned? too

Pure CSS for the border between two text areas -

Image
i got design between 2 menu options there 2px border. please see image: the tricky thing border shorter height of menu texts. the menu texts have in 2 lines, exact way shown. have more items different width of text. have pure css solution it, cannot figure out right way. tried different ways , got closest: <div style="height: 15px; display:inline-block; border-left: 2px solid red; padding:0 15px;">first<br/>item</div> <div style="height: 15px; display:inline-block; border-left: 2px solid red; padding:0 15px;">second<br/>item</div> see picture above work: the problem border not in middle vertically. how can make border stay in middle vertically? or other css way achieve shown in design? example :before pseudo element: https://jsfiddle.net/qfadxsyd/7/ .box:before { position:absolute; content:''; height:80%; right:-1px; width:2px; top:0; bottom:0; margin:auto; backgroun

gsp - using <set> tag in grails -

i new grails. came across set tag can use in gsp pages set values similar setting model controller. <g:set var="home" value="something" /> so when write ${home} outputs "something". is there way set value in sessions in gsp pages , not controller using set tag? yes can in gsp pages well. have include attribute scope indicate scopes(session, flash, page , request) setting value to. <g:set var="home" value="something" scope="session" /> if donot include scope option defaults request scope. to display the value have write ${session.home} or ${request.home} or ${home} request scope. hope helps. for more : https://grails.github.io/grails-doc/3.0.x/ref/tags/set.html

Internet Explorer browsers request extra 'none/' pages for all pages on my website -

Image
yesterday decided use php's error_log sending error messages e-mail address. received hundreds of letters, telling me there attempts load '%some_page%/ none/ ' links. example, user tries load page relative link 'contacts/', page loaded , displayed correctly, there request 'contacts/ none/ ' page, web-server needs handle twice more requests. these requests ie users only. tried myself load several pages ie 8, displayed correctly, browser tried load these stupid '/none' pages. the same error described here , solution not found. don't use cms. website passes w3 markup validation without errors. don't know , cannot find helpful information problem in web. screenshot of chrome's devtools. last update : figured out because of css rules 'behavior: url(/custom/css/border-radius.htc);'. removed them , worked!

javascript - Uncaught TypeError: Cannot set property 'className' of null.active -

it's sign in button , form both contain in 1 id mainbutton box, each of them has different z-index . when click signin-btn , form show out. occur problem doesn't work when click button, , chrome dev tools shows uncaught typeerror: cannot set property 'classname' of null' seemly wrong javascript openform() . var button = document.getelementbyid('mainbutton'); var openform=function() { button.classname = "active"; }; var checkinput = function(input) { if (input.value.length > 0) { input.classname = "active"; } else { input.classname = ""; } }; #mainbutton .active { box-shadow: 0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.22); } #mainbutton .active .signin-form { -webkit-transform: scale(1, 1); -moz-transform: scale(1, 1); -ms-transform: scale(1, 1); -o-transform: scale(1, 1); transform: scale(1, 1); } <div id=&

amazon web services - AWS Domain Transfer stuck in Step 14 -

i had initiated domain transfer on amazon. whois records show domain transferred gandi (aws technical domain provider). however, past 5 days, i've been seeing domain in "pending requests", , stuck in step 14 message: domain transfer in progress: sent email registrant contact: transfer complete (step 14 of 14) . but didn't receive email on registrant contact, , neither domain moving "registered domains" section in aws route 53 console. how long take? it took 8 working days clock. domain transfer complete.

java - Pass value of one application to other package application in background like facebook & facebook messenger app -

i have 2 app app1(package name-: com.abc.q) , app2(package name -:com.xyz.y) in app1 there activity open app2 activity has notification comes parse.com .i want whenever app2 gets notification should show "1" in app1 in small red oval.in gist when app2 gets notification parse.com should show red oval notification in app1 in activity have decided. app1 acivity 1.)gkk.java public class gkk extends activity { mediaplayer oursong; private static final string tag = "gkk"; button button;private progressdialog pdialog; private webview webview; private webview webview1; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); setcontentview(r.layout.lgin); webview = (webview) findviewbyid(r.id.webview1); webview1 = (webview) findviewbyid(r.id.webview11); webview.getsettings().setjavascriptenabled(true);

java - Generate Getters and setters without underscore (not prefix/suffix) + eclipse -

my variable private string category_code = null; my getter , setter generated public string getcategory_code() { return category_code; } public void setcategory_code(string category_code) { this.category_code = category_code; } is possible generate public string getcategorycode() { return category_code; } public void setcategorycode(string categorycode) { this.category_code = category_code; } i checked properties-->code style-->fields prefix , suffix. or should rename variables m_categorycode? , output follows? public string getcategorycode() { return m_categorycode; } public void setcategorycode(string categorycode) { m_categorycode = categorycode; } which better? java code tends follow camelcasestyle, not c_underscore_style. following existing standards in variety of ways (you able better read others' code , others able better read code, "others" oth

python - Tornado - JSON Output sent as Response to be wrapped in dictionary -

i came across section in docs : requesthandler.write(chunk) writes given chunk output buffer. to write output network, use flush() method below. if given chunk dictionary, write json , set content-type of response application/json. (if want send json different content-type, call set_header after calling write()). note lists not converted json because of potential cross-site security vulnerability. json output should wrapped in dictionary. more details @ http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ , https://github.com/facebook/tornado/issues/1009 so have few questions related this: what mean this? if given chunk dictionary, write json. what mean this? note lists not converted json because of potential cross-site security vulnerability. what mean this? , here, mean json output? , why wrap in dictionary? all json output should wrapped in dictionary. this has 2 subparts : a. best way sen

Github Desktop master not updating after merge branch -

when use github desktop merge local branch master, looks on remote version. master branch on github desktop doesn't update. when click sync , following error message: project has been updated on https://github.com/user/project.git since last synced. can try syncing again or run git pull origin master && git push origin master command line. when follow error message instructions, updated properly. next time pull , merge branches, same thing occurs. any thoughts on may have done cause , how can resolved? maybe local master branch has no upstream branch . next time, when following instructions, try: git pull origin master && git push -u origin master the -u ensure master has origin/master upstream branch. sync should work.

android - What is the path separator I should use in cocos2d-x to be platform independent? -

i building ios, android, , windows phone, , may support other platforms in future. currently this: std::string filename = resourcepath + "/" + result + ".plist"; it seems work ios (on simulator), haven't checked android / wp yet. right way add path separator ? there api or can use add separator correctly ? this use path separator in code: #if (cc_target_platform == cc_platform_win32) #define path_separator "\\" #endif #if (cc_target_platform == cc_platform_ios) #define path_separator "/" #endif #if (cc_target_platform == cc_platform_android) #define path_separator "\/" #endif static const std::string separator = path_separator; std::string nextbtnfilename = "images"+separator+"speech"+separator+"button_next.png"; hope helps!

javascript - How to create SVG with grid lines using D3JS -

i planning build graph designed user drag drop. want add grid lines it. doing like: var svg = d3.select("#canvas").append("svg") .attr("width", width) .attr("height", height); (var = 0; <= 10; i++) { svg.append("line") .attr("x1", i*60) .attr("y1", 0) .attr("x2", i*60) .attr("y2", 600) .attr("stroke-width", 0.5) .attr("stroke", "grey"); svg.append("line") .attr("x1", 0) .attr("y1", * 60) .attr("x2", 600) .attr("y2", * 60) .attr("stroke-width", 0.5) .attr("stroke", "grey"); } is there better way of doing this? also, except first , last lines in grid, other lines appearing thick. https://jsfiddle.net/krishnasar

Error creating table in MySQL using PHP -

i writing php script create database , use create table . assume using correct mysql syntax yet faing error - error creating table: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'use website; create table users ( id int(11) unsigned auto_increment pri' @ line 2 here php script - create_db.php <?php function create_database($hostname, $username, $password) { $h = $hostname; $u = $username; $p = $password; $conn = new mysqli($h, $u, $p); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "create database website; use website; create table users ( id int(11) unsigned auto_increment primary key, firstname varchar(255) not null, lastname varchar(255) not null, email varchar(255) not null, password varchar(255) not null, hash varchar(255) not null, forgot_password_has

ruby on rails - Connect Twilio phone number with Twiml app -

when buy new number twilio , connecting sms url recieve sms reply user following: twilio.object.account.incoming_phone_numbers.create( :phone_number => number, :sms_url => url ) but when change url have go through numbers , change sms url create twiml app. question is: can connect phone number when buy twiml app like: twilio.object.account.incoming_phone_numbers.create( :phone_number => number, :twiml_sid => sid // trying achieve ) or sms_url ! twilio evangelist here. you can absolutely this. set voiceapplicationsid parameter when creating new phone number: $number = $client->account->incoming_phone_numbers->create(array( "friendlyname" => "my company line", "voiceapplicationsid" => "apxxxxxxxxxxxxxxxxxxxxxxxxx", "phonenumber" => "+15105647903" )); hope helps.

Uknown Column new in FIELD LIST Mysql Trigger -

i have following trigger supposed insert on trigger table after insert. keep on getting following error : unknown column field in list below trigger : drop trigger if exists `trgr_client_statement_report`;create definer=`uniquelo`@`localhost` trigger `trgr_client_statement_report` after insert on `statement` each row insert trgr_statement ( `amnt_cr`, `amnt_dr`, `approved`, `clnt_id`,`date_added`,`days`, `description`, `discount`, `id_2`, `invoiced`, `invoice_no`, `job_card_id`, `payment_date`, `payment_status`, `pymnt_code`, `pymnt_mthd`, `qty`, `rcpt_no`, `status`) values ( new.`amnt_cr`,new.`amnt_dr`,new.`approved`,new.`clnt_id`,new.`date_added`,new.`days`,new.`description`,new.`discount`,new.`id`,new.`invoiced`,new.`invoice_no`,new.`job_card_id`,new,`payment_date`,new.`payment_status`,new.`pymnt_code`,new.`pymnt_mthd`,new.`qty`,new.`rcpt_no`,new.`status`) there syntax error in fieldlist. must use new.field not new,fi

static - Constant Variables in Java -

i'm creating static objects inside class this. want them constant seems did wrong because objects b c same (their x same). can explain why? public class key { private note[] sequence; private string name; public key() { this.sequence = note.notes; } public key(string name, note[] notes) { this.sequence = note.notes; this.name = name; for(int = 0; < this.sequence.length; i++){ for(int j = 0; j < notes.length; j++){ if(this.sequence[i].equals(notes[j])){ this.sequence[i].setintensity(0.6); break; } else this.sequence[i].setintensity((double)0); } } } private static final key c = new key("c", new note[]{note.f2, note.g2, note.a2, note.b2, note.c3, note.d3, note.e3, note.f3, note.g3, note.a3, note.b3}); private static final key csharp = new key("c#", new note[]{note.fsharp2, note.gsharp2, note.asharp2, note.c3, note.csharp3, note.dsharp3, note.f3, n

curl - How PHP get the content from web service? -

Image
i have problem in getting content/array web service php code. when type in url in browser http://server1-xeon.asuscomm.com/currency/?amount=1.20,from=myr,to=sgd , result in browser displayed this: [ 1.20myr , 0.39sgd ]. php code looks this: $ch = curl_init('http://server1-xeon.asuscomm.com/currency/?amount=1.20,from=myr,to=sgd'); curl_setopt($ch, curlopt_returntransfer, true); $content = curl_exec($ch); curl_close($ch); echo $content; unfortunately, nothing use code above. looking help. thanks. updated $data=array( 'amount'=>1.2, 'fromcurrency'=>'myr', 'tocurrency'=>'sgd' ); $data_string = json_encode($data); $ch = curl_init('http://server1-xeon.asuscomm.com/currency/webservice.asmx/yahoo_currencyex'); curl_setopt($ch, curlopt_customrequest, 'post'); curl_setopt($ch, curlopt_postfields, $data_string);

powershell - "Method Not found" error when calling GetElementsbyClassName -

Image
i created powershell automation script , gave friend when run it, said method invocation failed because [mshtml.htmlbodyclass] not contain method named 'getelementsbyclassname'. @ c:\users\עמית\documents\asaf.ps1:22 char:3 + $a=$docs.body.getelementsbyclassname("fadeout-scroll") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation: (:) [], runtimeexception + fullyqualifiederrorid : methodnotfound why happened? we both have ie11, .net 4.5, visual studio, have function , not. and looks here in computer ie console have function: but powershell not: how update powershell? found after alot of time: the missing want microsoft core xml

java - how to serialize multi-threaded program -

i have many threads performing different operations on object , when 50% of task finished want serialize everything(might want shut down machine ). when come want start point had left. how can achieve? this saving state of objects of game while playing. save state of object , retrieve back. here storing process's count/state. for example: i having thread creating salary excel sheet 50 thousand employee. other thread creating appraisal letters same 50 thousand employee. another thread writing "happy new year" e-mail 50 thousand employee. so imagine multiple operations. now want shut down in between 50% of task finishes. 25-30 thousand employee salary excel-sheet have been written , appraisal letters done 25-30 thousand , on. when come next day want start process had left. this resume . i'm not sure if might help, can achieve if threads communicate via in-memory queues. to serialize whole application, need disable consumption of queues,

c++11 - "Random" output from a determinstic C++ program. Possible causes? -

i'm using microsoft visual studio community 2015, version 14.xxx on 64-bit windows pc. the program reads text file in each line bridge deal (four players each 13 cards). file generated 3rd party program reliable validate each deal anyway , each input line passes validation. i group "similar" deals classes (bins) based on variables such number of points, suit length etc. standard text processing using stringstreams , map of bin structure. it's totally deterministic given input file. about 3/4 of time same output e.g. 23 possible bins - , frequency of deals across bins adds number of input deals, expected. remaining output might have 6 50 bins (with correct frequency totals). where might such randomness arise? use default initialization of variables so, if wrong, should consistent across program runs on given file. example, std::string line; // raw data on deal. std::vector<std::string> parsed_deal; std::map<std::string, struct bin> m_b

c# - Platform invoke #define directive -

i trying understand platform invokes. so, understood many concepts how can invoke #define directives in c#. example: in c++ side have this: #define dont_care_how_you_invoke_me (ptr) i've tried this: [dllimport("mydll.dll")] static extern void dont_care_how_you_invoke_me(intptr ptr); this didn't work. i've searched on google while , couldn't find i'm not sure if possible or not. thanks in advance pinvoke imported methods in c# correspond actual exported functions in dll, not c/c++ syntactical representation of function (which why use name-mangling when dealing member functions in c++) instead of using c/c++ header file reference functions, use tool see functions being exported dll , use names directly. a tool dependency walker: http://www.dependencywalker.com/

How to measure Python's asyncio code performance? -

i can't use normal tools , technics measure performance of coroutine because time takes @ await should not taken in consideration (or should consider overhead of reading awaitable not io latency). so how measure time coroutine takes ? how compare 2 implementations , find more efficent ? tools use ? one way patch loop._selector.select in order time , save io operations. can done using context manager: @contextlib.contextmanager def patch_select(*, loop=none): if loop none: loop = asyncio.get_event_loop() old_select = loop._selector.select # define new select method, used context def new_select(timeout): if timeout == 0: return old_select(timeout) start = time.time() result = old_select(timeout) total = time.time() - start new_select.iotime += total return result new_select.iotime = 0.0 # patch select method try: loop._selector.select = new_select yield n

java - hashCode changes each time the object is created -

there escapes me hashcode. know if override equals, must override hashcode too. know if 2 objects equal, hashcode of 2 objects must equal. if fields checked in equals method don't change, hashcode should not change, right? if so, can't understand why each time create instance of object below, different hashcode: public class effect { private long timestamp; private int damage; private squaretype squaretype; public effect(long timestamp, int damage, squaretype squaretype) { this.timestamp = timestamp; this.damage = damage; this.squaretype = squaretype; } public long gettimestamp() { return timestamp; } public int getdamage() { return damage; } public squaretype getsquaretype() { return squaretype; } @override public boolean equals(object o) { if (this == o) return true; if (o == null || getclass() != o.getclass()) return false; effect effect

html - jQuery dealing id="q1" and id="q10" as same -

i calling (from jquery) divs id="q0" , id="q1 "... id="q10" 1 one. when it(jquery) calls div="q1" calls div="q10" simultaneously. using characters @ end didn't work. //jquery $( document ).ready(function() { $(".container").hide(); var number=0; var question="question"; var question_number=question.concat(number); $('[id*='+question_number+']').show(); $(".submit").click(function (e) { $(".container").hide(); number++; var question_number=question.concat(number); alert(question_number); $('[id*='+question_number+']').show(); }); }); ////////////////html <div id="question1" class="container"> <button class="submit">submit</button> </div> /////so on <div id="question10" class="

excel - Message Box if Workbook opened outside 'Home' directory -

i administrator of small excel macro enabled membership database held , operated through dropbox , accessible selected individuals. i wondering whether possible set 'home' directory of workbook, if saved or copied individuals computer, or moved out of 'home', msgbox appears informing user workbook cannot opened in directory , closes. if possible, plan modify ask administrator password, if correct, workbook operates normally, if not, closes. thanks in advance.

node.js - Node JS - Pusher trigger -

the trigger function not working me in node js. pusher.trigger('test_channel', 'my_event', {"message": "hello world"}); i can not se in debug console pusher receiving data. there no problem debug console send event webpage client, client using privet channel , auth against server. know params right. using eu cluster in pusher , have config connect right server. var pusher = require('pusher'); var pusher = new pusher({ appid: '123', key: 'foo', secret: 'bar', encrypted: true }); pusher.domain = 'api-eu.pusher.com'; pusher.port = 443; pusher.trigger('test_channel', 'my_event', { "message": "hello world" }); do not realy know way, code made work. var pusher = new pusher.forurl(process.env.pusher_url);

elasticsearch custom_score multiplication is inaccurate -

i've inserted documents identical except 1 floating-point field, called a . when script of custom_score query set _score , resulting score 0.40464813 particular query matching fields. when script changed _score * a (mvel) same query, a 9.908349251612433, final score becomes 4.0619955. now, if run calculation via chrome's js console, 4.009394996051871. 4.0619955 (elasticsearch) 4.009394996051871 (chrome) this quite difference , produces incorrect ordering of results. why be, , there way correct it? if run simple calculation using numbers provided, result expect. curl -xpost 'http://127.0.0.1:9200/test/test?pretty=1' -d ' { "a" : 9.90834925161243 } ' curl -xget 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d ' { "query" : { "custom_score" : { "script" : "0.40464813 *doc[\u0027a\u0027].value", "query" : { "ma

retrieve error code from a command launched within a bash script -

ok i'm kind of new bash scripting [the advanced stuff] , need little help. don't know how phrase i'll explain doing , need know it. in script run ./configure , need able catch if there error in configure , react accordingly within bash script. the code is: function dobuild { echo -e "\e[1;35;40mexecuting bootstrap , configure\e[0m" cd /devel/xbmc if [ $debug = "1" ]; #either outputs screen or nulls output ./bootstrap >/dev/null /usr/bin/auto-apt run ./configure --prefix=/usr --enable-gl --enable-vdpau --enable-crystalhd --enable-rtmp --enable-libbluray >/dev/null else ./bootstrap /usr/bin/auto-apt run ./configure --prefix=/usr --enable-gl --enable-vdpau --enable-crystalhd --enable-rtmp --enable-libbluray fi } and configure returns error 1 or 2 how trap , act on it? tia after execution of command, returned value stored in shell variable $?. have match return values of success , failure if [ $? == 1 ] #do else #do else

html - Is it possible to position items around the circle? -

Image
i trying make circle , put 3 equals part around it. saw image below in site, want 3 equals part , not four. i want them (the parts) button. if click them refer page. i tried lot without success. goal each button around circle refer page. possible html , css? , if yes, how? using css: one pure css way create shape use css skew transforms. since need click events on parts, better use separate elements instead of using pseudo-elements. .outer { position: relative; height: 200px; width: 200px; border-radius: 50%; border: 2px solid; overflow: hidden; } .inner { position: absolute; height: 50%; width: 50%; top: calc(25% - 2px); left: calc(25% - 2px); border-radius: 50%; background: yellowgreen; border: 2px solid; } .part { position: absolute; height: 100%; width: 100%; } .part:nth-child(2) { top: -50%; left: calc(-50% - 2px); transform: skewy(-30deg); transform-origin: right bottom; background